If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Password()

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-14-10, 16:25
Gazzieh Gazzieh is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
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?
Reply With Quote
  #2 (permalink)  
Old 06-14-10, 16:34
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
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.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old 06-14-10, 16:41
Gazzieh Gazzieh is offline
Registered User
 
Join Date: Jun 2010
Posts: 2
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On