Page 1 of 1
how to check a url? :/
Posted: Sat Apr 26, 2003 7:18 am
by qads
hi guys,
i am makeing a search engine and would like to know how i can check a web site address to make sure that it is up and running?
I have been trying with curl_* functions with no luck and google search didn't really help either

.
thanks for your time
fopen 404 page not found update mysql php
Posted: Sat Apr 26, 2003 9:41 am
by phpfreak
use this code :
assumptions in this code: You have the url of the website in your database called SOMETHING AND THE TABLE IS ALLURL.
the code just uses the fopen function of the php and tries to open the domain, remember in your php.ini file you have to have your allow_url_fopen="On" , for this to work right. The allow_url_fopen function helps in opening the files from other domain.
===============================================
(mod_edit: [ php ] tag and indents)
Code: Select all
<?
$connection=mysql_connect("localhost") or die("no connection dude");
mysql_select_db("something");
$result = mysql_query("SELECT Url FROM allurl");
$contenu = " ";
?>
<?
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$first= strtolower($row["Url"]);
$fp = @fopen($first,"r");
if ($fp)
{
echo "$first ::: Exists!!!";
//below statement updates the table by inserting a no in the column error_404 and inserts a yes if is not found
$sql="update allurl set Error_404 ='No' where Url='$first'";
$connection_1=mysql_connect("localhost") or die("no connection dude");
mysql_select_db("something");
$sql_result = mysql_query($sql, $connection_1) or die("NOT ABLE TO EXECUTE QUERY !");
}
else
{
echo "$first ::: does not exist";
$sql="update allurl set Error_404 ='Yes' where Url='$first'";
$connection_1=mysql_connect("localhost") or die("no connection dude");
mysql_select_db("something");
$sql_result = mysql_query($sql, $connection_1) or die("NOT ABLE TO EXECUTE QUERY !");
}
}
mysql_free_result($result);
?>
===============================================
hope it helped
regards,
srinivas