Forum Moderators: coopster

Message Too Old, No Replies

mysql_num_rows throws error

php database

         

makeithappen

9:35 pm on Jul 21, 2012 (gmt 0)

10+ Year Member



please i need help

part of my script below:

13 $query = "Select * from members where member_id = '". $sponsorsid ."' and activated = 1" ;
14 $result=mysql_query($query);
15$num=mysql_numrows($result);


error is:

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/followup/public_html/default.php on line 15



i decided to add this line to it-


die( "Unable to query the database" . mysql_error());


this is the erroor message i get below with blank page

Unable to query the databaseNo database selected


please what do i do now as i am really worried on how to figure this out.

robzilla

11:39 pm on Jul 21, 2012 (gmt 0)

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



It's mysql_num_rows, not mysql_numrows :-)

As for the "No database selected" error, are you establishing a connection to the database anywhere in your script, and selecting a specific database?

makeithappen

3:07 pm on Jul 22, 2012 (gmt 0)

10+ Year Member



okay i have done it.


but i still have this error?


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/cashscom/public_html/default.php on line 15

yes am establishing a connection to the database. but the config.php seems to be okay from my end



ERROR



Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/followup/public_html/default.php on line 15

makeithappen

3:09 pm on Jul 22, 2012 (gmt 0)

10+ Year Member



new error


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/followup/public_html/default.php on line 15

robzilla

5:36 pm on Jul 22, 2012 (gmt 0)

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



What that basically says is that the query result you pass on to mysql_num_rows is invalid.

Try using var_dump() [php.net] to display what the $result variable holds after querying the database.

makeithappen

5:40 pm on Jul 22, 2012 (gmt 0)

10+ Year Member



ok let me try it now

makeithappen

7:29 pm on Jul 22, 2012 (gmt 0)

10+ Year Member



still getting this error


bool(false)
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/followup/public_html/default.php on line 16

ergophobe

7:44 pm on Jul 22, 2012 (gmt 0)

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



I would suggest testing your query in a MySQL client and make sure your query works as expected, and debug from there.

makeithappen

6:18 am on Jul 23, 2012 (gmt 0)

10+ Year Member



am abit of a novice.... please what is the steps in going about this please

ergophobe

5:46 pm on Jul 24, 2012 (gmt 0)

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



You can go into PHPMyAdmin on your server and just enter the query and see if it actually works and return what you expect it to return. Then at least you'll know which tree to bark up.

makeithappen

7:19 pm on Jul 24, 2012 (gmt 0)

10+ Year Member



yes guys. am fine now. my script is working perfectly

you guys are the best.


Thank you so much ergophobe and robzilla