Jump to content

Archived

This topic is now archived and is closed to further replies.

cwolf2

My RPG needs fixing!

Recommended Posts

I am trying to make a new RPG from scratch, and I\'m not that good at php or MySQL (only been at it for like, two months). But I know a good bit of MySQL and PHP, but there\'s an error on my game. When I log in, it says this:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site50/fst/var/www/html/aerorpg/login.php on line 6

And when I look in the source code, I have this there...

$logres = mysql_num_rows(mysql_query("select * from ae_players where user=\'$user\' and pass=\'$pass\'"));

I created a table called \"ae_players\" and I put in the fields \"user\" and \"pass\" and \"email\" but now it\'s saying it\'s wrong?? How is it wrong?? Can anyone help???????

Share this post


Link to post
Share on other sites

Mysql_num_rows counts the results from a query. From what I see, it would basically give you an answer of \"1\" or \"0\" because either one or no players have the specified username and password. Try this instead:

 

$query="SELECT * FROM ae_players WHERE user=\'$user\' AND pass=\'$pass\'";

$logres = mysql_query($query,$db);

$return_count = mysql_num_rows($logres);

 

Notice the $db varible. You aren\'t getting an error because of that, but I always put my DB connections in with the query.

 

BTW: from your post, you didn\'t specify what you needed the mysql_num_rows for... From what I see, it has no purpose, unless you wanted to see if the result returned true or not.

 

Also, just a tip from someone who began PHP/MySQL just a while ago too... take advantage of the variables :) Notice I split up your query, and other parts. That makes it much neater, and easier to find problems later on. It\'s an awsome function :)

 

This this post didn\'t help, please post again, and I\'ll try again :P

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.