billwatson
Instructor
hi
dont know much php but have been attempting to alter a downloaded piece of code to perform a search on a mysql database and return the results to flash
<?php
mysql_connect("localhost","bill","pass");
mysql_select_db("products");
$table = "produce";
$condition = $HTTP_POST_VARS['word'];
$qr = mysql_query("SELECT * FROM $table WHERE product LIKE $condition");
$r_string = 'n='.mysql_num_rows ($qr);
$i = 0;
while ($row = mysql_fetch_assoc ($qr)) {
while (list ($key, $val) = each ($row)) {
$r_string .= '&' . $key . $i . '=' . $val ;
}
$i++;
}
echo $r_string;
?>
the code returns the following errors
PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\phpdev\ on line 9
PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\phpdev\ on line 11
any pointers as to what I am doing wrong will be greatly appreciated
dont know much php but have been attempting to alter a downloaded piece of code to perform a search on a mysql database and return the results to flash
<?php
mysql_connect("localhost","bill","pass");
mysql_select_db("products");
$table = "produce";
$condition = $HTTP_POST_VARS['word'];
$qr = mysql_query("SELECT * FROM $table WHERE product LIKE $condition");
$r_string = 'n='.mysql_num_rows ($qr);
$i = 0;
while ($row = mysql_fetch_assoc ($qr)) {
while (list ($key, $val) = each ($row)) {
$r_string .= '&' . $key . $i . '=' . $val ;
}
$i++;
}
echo $r_string;
?>
the code returns the following errors
PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\phpdev\ on line 9
PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\phpdev\ on line 11
any pointers as to what I am doing wrong will be greatly appreciated