Need help with MySql on my website.

Many of us have Small Office/Home Office Networks or want to set one up. Possibly just to share the Internet among multiple computers. This forum is about networking: set up, hardware - hubs, routers, etc.
Post Reply
Smitty

Need help with MySql on my website.

Post by Smitty » December 3rd, 2010, 10:32 am

Hello, I just made a new website and login system in php. When I try to login on my new site I get:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a8003981/public_html/index.php on line 313

That only happens when I put it on 000Webhost.com, when I use the WAMP server at my home computer, it works fine.

Any suggestions are appreciated.

User avatar
WCCobra
Site Admin
Posts: 1000
Joined: March 11th, 2010, 1:00 pm
Contact:

Re: Need help with MySql on my website.

Post by WCCobra » December 3rd, 2010, 11:20 am

We would need to see the whole line. It should read something similar to

mysql_num_rows(SELECT _______ FROM _______ WHERE _______ )

irrelevant
Site Admin
Posts: 356
Joined: March 11th, 2010, 1:00 pm

Re: Need help with MySql on my website.

Post by irrelevant » December 3rd, 2010, 12:23 pm

Is the hosting Windows or Linux?

and are the versions of mysql the same?

is this the only problem? or are there other areas of the site that do not work correctly?

Smitty

Re: Need help with MySql on my website.

Post by Smitty » December 7th, 2010, 10:24 am

This is the code in the login page. The server os is Linux. I am not sure if the versions are the same.



//Gives error if user dosen't exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database. <a href=/Register/>Click Here to Register</a>');
}
while($info = mysql_fetch_array( $check ))
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);

User avatar
WCCobra
Site Admin
Posts: 1000
Joined: March 11th, 2010, 1:00 pm
Contact:

Re: Need help with MySql on my website.

Post by WCCobra » December 7th, 2010, 3:15 pm

Too far into the code to tell what's the problem. You need to post the earlier bits.

Notes:
  • You can throw the mysql_num_rows($check) right into the if-statement and remove the $check2 variable
  • You should not be using MD5 without a salt
  • Global variables are a no-no... use cookies (not for passwords) or sessions

Post Reply

Return to “Networking”