View Single Post
Old 02-27-2012, 09:56 PM   #1
Join Date: Jan 2011
Posts: 41
Default mysql_num_rows() error

I am trying to create a search engine of sorts on a site for my client. the php code is

PHP Code:
$_GET ['k'];
$terms explode(" "$k);        
$query "SELECT * FROM search WHERE ";

        foreach (
$terms as $each){

            if (
$i == 1)
$query .= "keywords LIKE '%$each%' ";
$query .= "OR keywords LIKE '%$each%' ";
// connect
$query mysql_query($query);
$numrows mysql_num_rows($query);
        if (
$numrows 0){
            while (
$rows mysql_fetch_assoc($query)){
$title $rows['title'];
$description $rows['description'];
$keywords $rows['keywords'];
$link $rows['link'];
"<h2><a href='$link'>$title</a></h2>
$description<br /><br />";
"No results found for \"<b>$k</b>\"";
when i submit this form:
PHP Code:
<form method="get" action="results.php">
    <input type="text" name="k" size="30" value="<?php echo $_GET['k']; ?>"/>
    <input type="submit" value="Search" />
i get this error:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ***.php on line 228

I've been searching around for why this happens and i haven't found a reason that helps me. This is my first time teaching myself and trying to learn phpmyadmin and mysql databases so i don't know if maybe I'm doing something wrong...

thank you so much for any help you can offer!
sydesign is offline   Reply With Quote