Skip to main content
edited tags
Link
Harikrishnan
  • 9.9k
  • 11
  • 87
  • 128
edited tags
Link
Harikrishnan
  • 9.9k
  • 11
  • 87
  • 128
deleted 4 characters in body; edited tags
Source Link
Harikrishnan
  • 9.9k
  • 11
  • 87
  • 128

How can I detect Thisthis error using php curl? curl return success even if the URL does not exist.

  Not Found
 
The requested URL /foo/index.php/items/edit was not found on this server.

My code

$post_fields = array('info' => json_encode($fields));
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($post_fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLINFO_CONTENT_TYPE,'application/x-www-form-urlencoded charset=utf-8');

    $result = curl_exec($ch);
    echo $result;

    if(curl_error($ch)){
        $result = curl_error($ch);
        curl_close($ch);
        return $result;
    }else{
        curl_close($ch);
        return json_decode($result,true);

    }

How can I detect This error using php curl? curl return success even if URL does not exist.

  Not Found
 
The requested URL /foo/index.php/items/edit was not found on this server.

My code

$post_fields = array('info' => json_encode($fields));
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($post_fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLINFO_CONTENT_TYPE,'application/x-www-form-urlencoded charset=utf-8');

    $result = curl_exec($ch);
    echo $result;

    if(curl_error($ch)){
        $result = curl_error($ch);
        curl_close($ch);
        return $result;
    }else{
        curl_close($ch);
        return json_decode($result,true);

    }

How can I detect this error using php curl? curl return success even if the URL does not exist.

Not Found
The requested URL /foo/index.php/items/edit was not found on this server.

My code

$post_fields = array('info' => json_encode($fields));
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($post_fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLINFO_CONTENT_TYPE,'application/x-www-form-urlencoded charset=utf-8');

    $result = curl_exec($ch);
    echo $result;

    if(curl_error($ch)){
        $result = curl_error($ch);
        curl_close($ch);
        return $result;
    }else{
        curl_close($ch);
        return json_decode($result,true);

    }
deleted 7 characters in body
Source Link
Harikrishnan
  • 9.9k
  • 11
  • 87
  • 128
Loading
Source Link
Harikrishnan
  • 9.9k
  • 11
  • 87
  • 128
Loading