Forum Moderators: coopster

Message Too Old, No Replies

Multiple mysql_num_rows in one script

         

sfbill

4:47 pm on Mar 7, 2005 (gmt 0)

10+ Year Member



I am having trouble using the mysql_num_rows script multiple times in one script...it works fine the first time, then every subsequent time it gets an error (using the same syntax.) Is there something I need to do to reset this function? I tried using mysql_data_seek($users,0); but it didn't work. Any help appreciated. I use it on a different table here, but also on the same table with different select criteria later...

//Total User Count
$countusers = "SELECT * FROM Users";
$users = mysql_query($countusers, $link);
$count_users = mysql_num_rows($users);

//Total Survey Count
$countsurveys = "SELECT * FROM Survey1";
$surveys = mysql_query($countsurveys, $link);
$count_surveys = mysql_num_rows($surveys);

/////////////////////////////////////

grandpa

5:04 pm on Mar 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi sfbill, and Welcome to WebmasterWorld!

What error are you getting?

You might try to free the previous query results - mysql_free_result() - Although if you're getting the num_rows from different tables...

sfbill

5:35 pm on Mar 7, 2005 (gmt 0)

10+ Year Member



Thanks for the help...the error was this:

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

Turned out to be a bad table name! Sorry for posting this.

grandpa

5:37 pm on Mar 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorry for posting this.
Been there, done that!

Glad you got it worked out.