Jump to content

SEARCH ENGINE CODE (PHP) I NEED HELP!


GPCoin

Recommended Posts

I can never understand php, Another error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'seanhall_search'@'free.monkeyserve.com' (using password: YES) in /home/seanhall/public_html/search.php on line 14

 

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 16

 

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 16

SELECT * FROM searchengine WHERE keywords LIKE '%test%'

Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 29

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 29

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 30

oh and also if you type age of war a page i had added in the mysql to test it, this pops up:

you searched for age of war

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'seanhall_search'@'free.monkeyserve.com' (using password: YES) in /home/seanhall/public_html/search.php on line 15

 

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 17

 

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 17

SELECT * FROM searchengine WHERE keywords LIKE '%age%'

Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 30

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 30

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 31

No results Found.SELECT * FROM searchengine WHERE SELECT * FROM searchengine WHERE keywords LIKE '%age%' OR keywords LIKE '%of%'

Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 30

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 30

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 31

No results Found.SELECT * FROM searchengine WHERE SELECT * FROM searchengine WHERE SELECT * FROM searchengine WHERE keywords LIKE '%age%' OR keywords LIKE '%of%' OR keywords LIKE '%war%'

Warning: mysql_query() [function.mysql-query]: Access denied for user 'seanhall'@'localhost' (using password: NO) in /home/seanhall/public_html/search.php on line 30

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/seanhall/public_html/search.php on line 30

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/seanhall/public_html/search.php on line 31

No results Found.

got it to connect it to mysql ussing this:

      $db_host = "localhost";
	$db_username = "seanhall_search";
	$db_pass = "*****";
	$db_name = "seanhall_search";

	@mysql_connect("$db_host","$db_username"."$db_pass")

 

and i have got this error:

 

 

Parse error: syntax error, unexpected T_VARIABLE in /home/seanhall/public_html/search.php on line 22

 

here is line 22

$search_exploded = explode(" ",$search);

hopefully this is the last error

 

lines 22-36:

$search_exploded = explode(" ",$search);

 

foreach($search_exploded as $search_each) {

$x++;

if ($x==1) {

$construct .= "keywords LIKE '%$search_each%'";

} else {

$construct .= " OR keywords LIKE '%$search_each%'";

}

$construct = "SELECT * FROM searchengine WHERE $construct";

echo $construct;

$run = mysql_query($construct);

$found = mysql_num_rows($run);

if ($found==0) {

echo "No results Found.";

gotta wrap that sucker....lol

 


<?php


$search = $_GET['search'];

if (!isset($search)) {
echo "Please enter a keyword!";
} else {
if (strlen($search)<=2){
echo "search term to short";
} else {   
echo "you searched for $search <hr size='1'>";
}

        $db_host = "localhost";
      $db_username = "seanhall_search";
      $db_pass = "*****"; //i edited the password
      $db_name = "seanhall_search";
      
      @mysql_connect("$db_host","$db_username"."$db_pass"); // i added a semicolon here
      
$search_exploded = explode(" ",$search);

foreach($search_exploded as $search_each) {
$x++;
if ($x==1) {
$construct .= "keywords LIKE '%$search_each%'";
} else {
$construct .= " OR keywords LIKE '%$search_each%'";
}
$construct = "SELECT * FROM searchengine WHERE $construct";
echo $construct;
$run = mysql_query($construct);
$found = mysql_num_rows($run);
if ($found==0) {
echo "No results Found.";
} else {
echo  "$foundnum results found!<p>";

         while ($runrows = mysql_fetch_assoc($run)) {

           $title = $runrows['title'];

           $desc = $runrows['description'];

           $url = $runrows['url'];

           

           echo "

            <b>$title</b><br>

            $desc<br>

            <a herf='$url'>$url</a><br>

           ";



          }

    }

}

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.