Hey, I am about to go insane so please can someone come to my aid lol. My code: function download($url) { $curl = curl_init(); if($curl) { if( !curl_setopt($curl, CURLOPT_URL, $url) ) return "FAIL: curl_setopt(CURLOPT_URL)"; if( !curl_setopt($curl, CURLOPT_HEADER, true) ) return "FAIL: curl_setopt(CURLOPT_HEADER)"; if( !curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: text/xml,application/xml,application/xhtml+xml,text/html,;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept-Language: en-us,en;q=0.5", "Connection: keep-alive", "User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.4) Gecko/20070625 Ubuntu/7.10 (gutsy) Firefox/3.0.0.7", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive: 300")) ) return "FAIL: curl_setopt(CURLOPT_HTTPHEADER)"; $ret = curl_exec($curl); if( !$ret ) return "FAIL: curl_exec()"; curl_close($curl); if (strpos($ret, "Payment Required") > 0) { return "Payment is required <br />"; } else { return $ret; } } else return "FAIL: curl_init()"; } Code (markup): Sample of cURL output: Why would that show when I am asking it to return "Payment is required <br />" if the $ret var contains the string "Payment Required"? Any help would be appreciated
I'm not sure what the script actually does, but an HTTP 402 error literally means that a payment is required. http://modemhelp.net/httperrors/402.shtml Not much help but I don't have much to go off. How is the function being called? What is the function "download" doing (downloading what file?)?
$ret is set to the return value of curl_exec which is a boolean true or false. You are then using strpos to look and see if the string "Payment Required" is in $ret (which it can't be) anywhere other than right at the start. So, your function will return $ret, which is equal to true rather than returning the "Payment is required <br />" string, assuming all those curl functions succeed and don't return the error strings.