search engine database error

for som reason my numrows is wrong my sites code is

[php]

Xedgo - Search
<form action='results.php' method='get'>
	<input type='text' name='input' size='50' value='<?php echo $_GET['input']; ?>' class="sarch-field" /> 
	<input type='submit' value='Search' class="seach-button">
</form>
</center>
<br/>

<?php
	$input = $_GET['input'];//Note to self $input in the name of the search feild
	$terms = explode(" ", $input);
	$query = "SELECT * FROM search WHERE ";
	
	foreach ($terms as $each){
		$i++;
		if ($i == 1)
			$query .= "keywords LIKE '%$each%' ";
		else
			$query .= "OR keywords LIKE '%$each%' ";
	}
	
	// connecting to our mysql database
	mysql_connect("*****", "******", "*******");
	mysql_select_db("searchengiene");
	
	$query = mysql_query($query);
	$numrows = mysql_num_rows($query);
	if ($numrows > 5){
		
		while ($row = mysql_fetch_assoc($query)){
			$id = $row['id'];
			$title = $row['title'];
			$description = $row['description'];
			$keywords = $row['keywords'];
			$link = $row['link'];
			echo "<h2><a href='$link'>$title</a></h2>
			$description<br /><br />";

		}
		
	}
	else
		echo "No results found for \"<b>$input</b>\"";
	
	// disconnect
	mysql_close();
?>
[/php]

i modified your post to remove your database credential please do not include such information in the fureture also please use the php block quote

there might be an error with you database access or quest replace part of your codes with mine so that you can see if there is an error.

[php]
// connecting to our mysql database
mysql_connect(“", "", "******”) or die(mysql_error());
mysql_select_db(“searchengiene”) or die(mysql_error());

	$query = mysql_query($query) or die(mysql_error());
	$numrows = mysql_num_rows($query) or die(mysql_error());

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service