mysql_num_rows() error.....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
struggling_student
Forum Newbie
Posts: 15
Joined: Mon Feb 23, 2004 3:51 pm

mysql_num_rows() error.....

Post 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?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
Post Reply