Jump to content


Photo

My RPG needs fixing!


  • Please log in to reply
1 reply to this topic

#1 cwolf2

cwolf2
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 November 2003 - 10:38 PM

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

#2 triphis

triphis
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 19 November 2003 - 03:12 AM

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
Xac Attack




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users