Click here to Skip to main content
12,501,472 members (56,422 online)
Click here to Skip to main content

Stats

80.1K views
14.4K downloads
114 bookmarked
Posted

Making a Search Engine

, 3 May 2013 CPOL
This article discusses the making of a search engine.
<?
// check is url is in db
$lnk =htmlspecialchars( $_POST['link']);

 $link = mysql_connect('localhost', 'root', 'root')
    or die('Could not connect: ' . mysql_error());
	

mysql_select_db('crawler') or die('oops! seems like we have encounter some problem');

$query = "SELECT count(*) as 'count' ,state  FROM url_webpage where url like'".($lnk)."%' ;";
$result = mysql_query($query) or die('you can not use illegal charecter');


$line = mysql_fetch_array($result, MYSQL_ASSOC);
 $count=$line['count'];
 if ($count>0) 
    {
    if($line['state']==0)
	  { echo 'we have your site in our database and will be crawled very soon</br> your site priority hav been moved to the highest.';	  }
	elseif($line['state']==1)
	  {echo 'we are crawling currently your site';}
	elseif($line['state']==2)
	  {echo 'You site have already been crawled';}
	}
 else
 { mysql_free_result($result); 
 $query = "insert into url_webpage values('".md5($lnk)."','".$lnk."',0,null,0,4,' ');";
// echo $query;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
echo 'Thank you for adding your site we will soon crawl your site.';
 }
 
// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);



?>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

kburman6
Student
India India
I just love coding. But due to my studies it became very tough for me to manage both.

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160919.1 | Last Updated 4 May 2013
Article Copyright 2013 by kburman6
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid