0

Hi, need some help with the a php code i made to a search engine, i get a error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/eoopoedt/public_html/sok/search.php on line 49

Can some one fiks my code, and give me the right code:

<?php
$button = $_GET['submit'];
$search = $_GET['search'];

if (!$button)
echo "Søket samsvarer ikke med noen dokumenter. <br>
Prøv igjen senere.";
else
{
	if (strlen($search) <=0) 
	echo "Søket samsvarer ikke med noen dokumenter. <br>
Prøv igjen senere.";
else
{
	echo "søkeordet ditt: <b>$search</b> <hr size = '1'>";
	mysql_connect("localhost","eoopoedt","200152007w");
	mysql_select_db("eoop");
	$search_exploded = explode (" ",$search);
	foreach($search_exploded as $search_each)
	{
		$x++;
		if ($x=1)
		$construct .="keywords AND url AND title LIKE '%$search_each%'";
		else
		$constuct .= "OR keywords AND url AND title LIKE'%$search%'";
	}
	$constryct = "SELECT * FROM søkemotor WHERE $construct";
	$run = mysql_query($construct);
	$foundnum = mysql_num_rows($run);
	if ($foundnum == 0)
	echo "Ingen treff på søkeordet ditt.";
	else
	{
		echo "$foundnum resultater funnet på søkeordet ditt";
		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><p>";
		}
	}
}
}
		
?>
3
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by diafol
0

Have you tried reading the sticky at the top of this forum? It sounds like your problem is very similar to the one listed there, and your answer might be in that thread.

0
$constryct = "SELECT * FROM søkemotor WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);

Should be:

$construct = "SELECT * FROM søkemotor WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
0

I still get the error :S

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

0
SELECT * FROM `søkemotor` WHERE $construct

AND

$construct .="keywords AND url AND title LIKE '%$search_each%'";
		else
		$constuct .= "OR keywords AND url AND title LIKE'%$search%'";

doesn't make sense

perhaps:

if ($x=1){
	$construct .="keywords LIKE '%$search_each%' AND url LIKE '%$search_each%' AND title LIKE '%$search_each%'";
}else{
	$constuct .= "keywords LIKE '%$search_each%' OR url LIKE '%$search_each%' OR title LIKE'%$search%'";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.