View Feed
group-icon
Databases
Discuss databases and writing database queries with fellow DB enthusiasts.
296 Members
Join this group to post and comment.
manojsinghrana
manojsinghrana • Jan 3, 2011

Creating Search Engine: MySQL Warning

hello,

i am creating a search engine..

and i am getting an error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\wamp\www\major project\search.php on line 22

in the command written below

sql_select_db ("music_park");

$get= mysql_query("SELECT * from searchengine");
while ($getrow= mysql_fetch_assoc($get))
{

//explode our search

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

foreach ($search_explode as $search_each)
{
//construct query

$x++;
if ($x==1)

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

}

//echo out construct

$construct = "SELECT * from searchengine WHERE '$construct'";
$run = mysql_query ('$construct');
$foundnum = mysql_num_rows('$run');

if ($foundnum ==0)
echo "no result found";
else
{
echo "$foundnum result found!

";
}
}


please somebody help me out to remove this error..

thank you very much...!!!

Manish Goyal
Manish Goyal • Jan 3, 2011
Re: warning message

which database are you using for this?
manojsinghrana
manojsinghrana • Jan 3, 2011
Re: warning message

hello,
if you are asking me the name of my database then it is music_park.

and i am working on wampserver.
Manish Goyal
Manish Goyal • Jan 3, 2011
no i am asking are you using mysql or something else
silverscorpion
silverscorpion • Jan 3, 2011
Wamp server uses MySQL only..

Well, I don't see mysql_connect function being used to connect to the database first.
If you have used it in the code before, fine.

Also, use mysql_select_db instead of sql_select_db. That seems to be the only mistake to me.. try it.

You can also try printing the result of your query to know if the query is actually executed or not.
After the mysql_query line, just include a line to print the variable get.

$get = mysql_query("SELECT * from searchengine");
echo $get;
Now you'll know what is stored in the variable when you are running the while loop.
manojsinghrana
manojsinghrana • Jan 16, 2011
yes i am using mysql.
garima8905
garima8905 • Oct 16, 2011
sir, please help me to make a project in search engine in asp.net.
garima8905
garima8905 • Oct 16, 2011
Re: warning message

can you help me by guiding me how to make a search engine.?

Share this content on your social channels -