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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.";

Link to comment
Share on other sites

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>

           ";



          }

    }

}

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.