#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2

    Login Function Stopped Working


    Everything worked great on wamp, but when I uploaded my files to a live server i'm getting the following error. I don't see where or how it should be expecting a second parameter.

    Warning: mysql_result() expects parameter 1 to be resource, boolean given

    PHP Code:
    function login($username$password){
        
    $user_id user_id_from_username($username);
        
        
    $username sanitize($username);
        
    $password sanitize($password);
        
        return (
    mysql_result(mysql_query("SELECT COUNT(`ID`) FROM `members` WHERE `username` = '$username' AND `password` = pwdencrypt('$password')"))==1) ? $user_id false;

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    SOLVED

    PHP Code:
        return (mysql_result(mysql_query("SELECT COUNT(`ID`) FROM `members` WHERE `username` = '$username' AND `password` = 'pwdencrypt($password)'"), 0)==1) ? $user_id false
  4. #3
  5. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Uh no, not solved. At least I hope not: you're comparing the password against the string "pwdencrypt(password)", not the actual hashed/encrypted password.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    Originally Posted by requinix
    Uh no, not solved. At least I hope not: you're comparing the password against the string "pwdencrypt(password)", not the actual hashed/encrypted password.
    Crap you're right thanks for pointing this out, gotta try to fix this.
  8. #5
  9. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    Originally Posted by requinix
    You sure it's pwdencrypt() and not, say, ENCRYPT or PASSWORD?
    pwdencrypt worked on wamp, and it did compare the password to the encrypted password at the time.

    The problem I'm having now is that mysql_result is expecting two parameters. The "0" in:

    PHP Code:
    pwdencrypt('$password')"), 0)==1) 
    Seems to bypass the need for a password altogether. As long as a registered username is entered the user is logged in.

    No "0" produces the error:
    Warning: mysql_result() expects at least 2 parameters, 1 given

    So far any other values I have tried have also produced errors. Any help would be appreciated this is pretty frustrating. I did test this without using an encrypted password an I'm still having the same issue.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    All good now

    PHP Code:
    return (mysql_result(mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username' AND `password` = password('$password')"),0)==1) ? $user_id false
  14. #8
  15. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Don't have a GTalk, just the three in my profile (of which I'm only watching one right now).

    So all taken care of then?
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    Originally Posted by requinix
    Don't have a GTalk, just the three in my profile (of which I'm only watching one right now).

    So all taken care of then?
    Yeah all set thanks.

IMN logo majestic logo threadwatch logo seochat tools logo