I get an error with this bit of code but I cant see anything wrong with it:
[PHP]$regnum = "SELECT * FROM $dbprefix.`users`";
$regnum2 = mysql_query($regnum);
$regnum3 = mysql_num_rows($regnum2);
$regtotal = $regnum3;[/PHP]
It just counts the number of users in a database... ive tried changing the prefix so its not using a variable, ive tried rearranging it...
This is probably a very simple mistake that Im just not picking up on...
The error is a mysql error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/pythonsb/public_html/forum/index.php on line 19
Any ideas?
thanks
Comments
Photoshop Tutorials- Coming soon
Premium PHP Scripts- Coming soon
Haha i should really do some work so i can remove all the coming soon's
$regnum = "SELECT * FROM `$dbprefix.users`";
$regnum2 = mysql_query($regnum);
$regnum3 = mysql_num_rows($regnum2);
$regtotal = $regnum3;
Photoshop Tutorials- Coming soon
Premium PHP Scripts- Coming soon
Haha i should really do some work so i can remove all the coming soon's
What i dont understand is that taht exact piece of code i had working in a different file... perhaps ill try changing some of the db stuff...it shouldnt make a difference tho
The Royal Ram
Photoshop Tutorials- Coming soon
Premium PHP Scripts- Coming soon
Haha i should really do some work so i can remove all the coming soon's
The Royal Ram
[php]$regnum2 = mysql_query($regnum) or die(mysql_error());[/php]
Also, you should always check the validity of a mysql result before using it for anything. In this case, the 'or die' will stop the script on a query error, but often times you don't want such intrusive error messages popping up. So it's best to test the result (mysql_query will return false on error) before using it in other functions like mysql_num_rows.
Webmaster-Talk.com
Chroder.com
Photoshop Tutorials- Coming soon
Premium PHP Scripts- Coming soon
Haha i should really do some work so i can remove all the coming soon's