Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <code>curl_getinfo()</code> to get the status code of the response like so:</p> <pre><code>// set up curl to point to your requested URL $ch = curl_init($fullcurl); // tell curl to return the result content instead of outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // execute the request, I'm assuming you don't care about the result content curl_exec($ch); if (curl_errno($ch)) { // this would be your first hint that something went wrong die('Couldn\'t send request: ' . curl_error($ch)); } else { // check the HTTP status code of the request $resultStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($resultStatus == 200) { // everything went better than expected } else { // the request did not complete as expected. common errors are 4xx // (not found, bad request, etc.) and 5xx (usually concerning // errors/exceptions in the remote script execution) die('Request failed: HTTP status code: ' . $resultStatus); } } curl_close($ch); </code></pre> <p>For reference: <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/List_of_HTTP_status_codes</a></p> <p>Or, if you are making requests to some sort of API that returns information on the result of the request, you would need to actually get that result and parse it. This is very specific to the API, but here's an example:</p> <pre><code>// set up curl to point to your requested URL $ch = curl_init($fullcurl); // tell curl to return the result content instead of outputting it curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // execute the request, but this time we care about the result $result = curl_exec($ch); if (curl_errno($ch)) { // this would be your first hint that something went wrong die('Couldn\'t send request: ' . curl_error($ch)); } else { // check the HTTP status code of the request $resultStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($resultStatus != 200) { die('Request failed: HTTP status code: ' . $resultStatus); } } curl_close($ch); // let's pretend this is the behaviour of the target server if ($result == 'ok') { // everything went better than expected } else { die('Request failed: Error: ' . $result); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload