As per request of a member, I wrote this script, that returns code that is received as http response from remote domain. This may be used to check either site is alive or dead or has any error. Simple example: get_url_status("http://www.digitalpoint.com") or die("Site not active at the moment"); PHP: Download: ATTACHMENT or try THIS MIRRIOR LINK Details: I hope it helps. regards
1.1 new release - with custom timeout MIRROR DOWNLOAD : http://www.apitalk.com/scripts/url_status/url_status-1.1.zip OR USE ATTACHMENT. regards
Thanks a lot! Can I get a "THIS MIRROR LINK PLEASE", the above link doesn't seem to work, it says its not a valid archive.
No Luck, here is the script I use. Your script does work but I do not know why it takes so long or maybe hits an infinite loop. <? $dbhost = 'MYSERVER'; $dbname = 'Z'; $dbuser = 'Y'; $dbpasswd = 'X'; include 'url_status.inc'; // Connect to mysql server $connect = mysql_connect($dbhost,$dbuser,$dbpasswd); if ( !$connect ) die( "Couldn't connect to MySql"); //Select user database mysql_select_db($dbname) or die ("Couldn,t open $database"); $SQL2 = "SELECT * FROM orders"; $result = mysql_query($SQL2); while ($db_field = mysql_fetch_assoc($result)) { $url_def = $db_field['url']; if($return_code = get_url_status($url_def)) { print "Site is allive, returned - $return_code"; #success } else { print "Site returned error - $return_code"; #error } } ?>
You must atleast test with single url first. If that works, I will give you code for multiple, the one you are doing is killing the server lol, dont mind. You even did not pass the timeout whih is by default 10 seconds. And if your database has 100 urls, 100*10 = 1000 seconds, each hit spends 1000 seconds means, server goes down within few minutes. regards
Can this script be used on proxy listing site? I mean, can I make the site query all the urls in my database, and simply show on the site how many are live and how many are dead. is this possible?
Don't use .inc as file extension for PHP files. They can be viewed as plain text in the user's browser. Not that it'd matter in this case, as there isn't any sensitive data, but it's a bad habit and should always be avoided.