views:

30

answers:

1

i don't know whats wrong with this sql query.

SELECT * FROM main WHERE key LIKE '%$word%'

its giving results in phpMyAdmin but giving warning while executing it in a php page.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

A: 

This warning means you are not passing a valid resource to mysql_fetch_array().

Make sure you check the return value of mysql_query() and just to be sure try dumping your query just before you call mysql_query().

$res = mysql_query($query);
if(! $res) {
 die('Query exec failed'.mysql_error());
}
codaddict
it's better not to kill your application instantly. consider to use trigger_error instead of die to get error info, and then finish application properly, with 500 error page
Col. Shrapnel