I have just checked+tested your script and your for loop works perfectly. However the 2 breaks; in your switch command may be prevent the for loop from working. I would suggest finding an alternative to using the switch command.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
What does $returnCode actually contain?
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch($returnCode){
case 404:
$result = 'ERROR -> 404 Not Found';
break;
default:
break;
}
I would suggest replacing the above with the below if it just has a number.
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($returnCode==404 || $returnCode=='404'){
$result = 'ERROR -> 404 Not Found';
}
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
If it returns the following and never returns 404 then that would make the switch statement useless.
Total time for request: 0.308465003967 XXXXXXXXXX3738246550#Messages Sent1
So I would suggest trying what I suggested in my previous post as it should work.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
I tested it and it worked in my tests but worked too well. It only reports 404 errors and if you got a 500 error then it would not be reported.
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch($returnCode){
case 404:
$result = 'ERROR -> 404 Not Found';
break;
default:
break;
}
Replace the above with the below:
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($returnCode!==200 || $returnCode!=='200'){
$result = 'ERROR -> Status '.$returnCode;
}
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Weird. Should have worked. :?:
Below is another piece of code you can try and hopefully it should work.
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($returnCode!=='200' || $returnCode!==200 ||$returnCode>200 || $returnCode<200
|| $returnCode!==(int)200 ||$returnCode>(int)200 || $returnCode<(int)200){
$result = 'ERROR -> Status '.$returnCode;
}
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
I believe it is the break; code in the switch statement. That is why I suggested replacing it with an if statement. But obviousley there is something fishy going on with the $returnCode variable.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259