Jump to content

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???????

Link to comment
https://forums.phpfreaks.com/topic/1391-my-rpg-needs-fixing/
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

Link to comment
https://forums.phpfreaks.com/topic/1391-my-rpg-needs-fixing/#findComment-4617
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.