Page 1 of 1

mysql_num_rows() error.....

Posted: Sat Mar 13, 2004 2:40 pm
by struggling_student
hi

when i run the following query:

$result = mysql_db_query( $thisdb, 'SHOW fields FROM $tablename");
$num = mysql_num_rows( $result);

i get the following error:

Warning: mysql_num_rows(): supplied arguement is not a valid MySQL result resource

I have echoed out the query and it knows what the variables are and it runs fine in MySQL front.

Can anyone help?

Posted: Sat Mar 13, 2004 2:52 pm
by markl999
http://php.net/mysql_db_query
"Note: This function has been deprecated since PHP 4.0.6. Do not use this function."

Try this instead.
$sql = 'SHOW fields FROM $tablename";
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows( $result);

Also add ' or die(mysql_error())' onto your mysql_connect() and mysql_select_db() lines.