The Little Guy Posted September 24, 2009 Share Posted September 24, 2009 I am using curl, it is getting urls from a page. I am having a problem when it comes to pages that don't send a response back. How can I check to see if a page responds back or not? $url = 'http://somesite.com/somepage.php'; mysql_free_result($sql); $base = parse_url($url); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // grab URL and pass it to the browser $opt = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); Quote Link to comment Share on other sites More sharing options...
Handy PHP Posted September 24, 2009 Share Posted September 24, 2009 Well, the most basic method would be to check if $opt has a value... If there isn't a response then no value would be set for $opt. Or am I missing something? Handy PHP Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted September 24, 2009 Author Share Posted September 24, 2009 I added both of these: curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); It seemed to fix the problem. but you know whey you go to a page via web browser, and the page just sits there and loads forever... basically that is what was happening. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.