Results 1 to 3 of 3

Thread: Password()

  1. #1
    Join Date
    Jun 2010

    Unanswered: Password()

    Hi everyone, new to this forum so if I am a little indelicate please forgive me.

    I have searched the forums but cannot find this answered currently:

    I have written some PHP that queries a mySQL database. My local version runs fine but when I upload the files it fails.

    I have one field called 'pass' that is a PASSWORD() defined password.

    I have then undertaken a series of tests and found the following out.

    If I select PASSWORD('password') I get an encrypted code that matches the field entry for the user whose password is 'password'.

    Yet if I run the SQL SELECT * FROM cmsusers WHERE pass = PASSWORD('password') then I get a zero return - which is wrong since I can see they match.

    I note that the type is varchar and the length is restricted to 20. Could this be due to truncation and if so, how do I avoid this?

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    What does your PASSWORD() function return? Could the result be longer than 20 characters? If your function can't return more than 20 characters, something else is your problem. If your function could return more than 20 characters, you have two choices: either shorten the return value or legthen the column from VARCHAR(20) to something as long or longer than the longest possible return value from your function.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jun 2010
    Yep, it was the length of the field. I read that mySQL 5.1 extended the password function to 41 characters. I therefore extended the field and recreated the user.

    Everything worked fine! I need to watch out for that in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts