Hi:

I am getting this error when I do the search of the site :

Search results

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ./search.php on line 38
query executed in 0.000 seconds.

in my html page I have this part calling the search.php file

HTML Code:
.....

<TD COLSPAN=3 ROWSPAN=2>
<form method='post' action='search.php'>
<input type="image"  SRC="images/Search-button.gif" value="Search" ALT ="Search" \
Name="Search"</TD>

<TD COLSPAN=5 ROWSPAN=2>
<input type="text" size="15" name='keyword'></form></TD>

........
Following is my search.php file:

PHP Code:

<?
/*                                                                                   
 * search.php                                                                        
 *                                                                                   
 * Script for searching a datbase populated with keywords by the                     
 * load-db.php-script.                                                               
 */
print "<html><head><title>My Search Engine</title></head><body>\n";
if( $_POST['keyword'] )
{
  /* Connect to the database: */
  mysql_connect("localhost","..","..")
    or die("ERROR: Could not connect to database!");
  mysql_select_db("db");
  /* Get timestamp before executing the query: */
  $start_time = getmicrotime();
  /* Execute the query that performs the actual search in the DB: */
  $result = mysql_query(" SELECT                                                     
                                p.page_url AS url,                                   
                                COUNT(*) AS occurrences                              
                            FROM                                                     
                                page p,                                              
                                word w,                                              
                                occurrence o                                         
                            WHERE                                                    
                                p.page_id = o.page_id AND                            
                                w.word_id = o.word_id AND                            
                                w.word_word = \"".$_POST['keyword']."\"              
                            GROUP BY                                                 
                                p.page_id                                            
                            ORDER BY                                                 
                                occurrences DESC                                     
                            LIMIT ".$_POST['results'] );
  /* Get timestamp when the query is finished: */
  $end_time = getmicrotime();
  /* Present the search-results: */
  print "<h2>Search results for '".$_POST['keyword']."':</h2>\n";
  for( $i = 1; $row = mysql_fetch_array($result); $i++ )
    {
      print "$i. <a href='".$row['url']."'>".$row['url']."</a>\n";
      print "(occurrences: ".$row['occurrences'].")<br><br>\n";
    }
  /* Present how long it took the execute the query: */
  print "query executed in ".(substr($end_time-$start_time,0,5))." seconds.";
}


print "</body></html>\n";
/* Simple function for retrieving the currenct timestamp in microseconds: */
function getmicrotime()
{
  list($usec, $sec) = explode(" ",microtime());
  return ((float)$usec + (float)$sec);
}
?>
I couldn't figure out what is going wrong. Any help is greatly appreciated.
mayflower