Jump to content

Recommended Posts

When any of my users try to login it is giving this error:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/myhouse/public_html/tradingspace/user_login.php on line 42

 

I went to this file and this is what the paragraph says:

 

$query = "select id from PHPAUCTION_users where username='$username' and password='".md5($MD5_PREFIX.$password)."' and suspended=0";

$res = mysql_query($query);

//print $query;;

if(mysql_num_rows($res) > 0)

{

$PHPAUCTION_LOGGED_IN = mysql_result($res,0,"id");

$PHPAUCTION_LOGGED_IN_USERNAME = $HTTP_POST_VARS[username];

session_name($SESSION_NAME);

 

Link to comment
https://forums.phpfreaks.com/topic/59194-solved-invalid-mysql-result-please-help/
Share on other sites

Change $res = mysql_query($query); to

 

$res = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);

 

Then you'll find out what the error is.

 

You can probably resolve most of the trouble by carefully processing user input before creating the query.

Ok, when I did that, this is what came up:

 

Error: Unknown column 'username' in 'where clause' with query select id from PHPAUCTION_users where username='myhouse' and password='645036f7dc456ff666d194daf21be791' and suspended=0

 

Not sure how to fix that error either...

I had a brainfart...lol.  I went into the PHPAdmin and the column was titled "nick", so I changed it to "username" and now it works.  Do you foresee any issues I may have with this fix?  I figured it was more standard than changing the other to nick...

Thanks so much for your help! 

Ok, it let me login twice, and now it is giving me this error:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/myhouse/public_html/tradingspace/login.php on line 9

 

Warning: Cannot modify header information - headers already sent by (output started at /home/myhouse/public_html/tradingspace/login.php:9) in /home/myhouse/public_html/tradingspace/login.php on line 18

 

There is nothing on line 9 or 18...

The header error is a result of output to the browser (the earlier error message!).  Fix the first error and the header error will disappear.

 

The first error is caused because your database query has failed.  If you add the error trap/display I suggested in my first reply .... tell us what you see.

Ok... I was doing that and it wasn't working.  Turns out, the first error was in users_login.php and the second error was in login.php... I was going to the same one.  Thanks for the help!  After eight hours in a row, everything looks the same!

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.