UPDATE IN MYSQL

Asked

Viewed 57 times

0

I have an encrypted field in the MYSQL database. I’m trying to update this way

UPDATE USUARIOS
SET SENHA = md5(1234)
WHERE ID = 216;

but give me this error message:

Error Code: 1406. Data Too long for column 'PASSWORD' at rom 1

  • What is the USUARIOS table creation script?

  • The number of characters returned by md5() must have exceeded the limit of senha

  • 1

    the password column is varchar(20)

  • 1

    Md5 does not generate a 32 chars hash ?

  • So it kind of encrypts, if it only has 20 spaces?

  • 2

    Hence "Too long data" error. Increase to 32 and test

  • Count how many characters there are in $SENHA https://ideone.com/7Xx0D1

  • I increased to varchar(100) and it changes, but at the time of I do the loguin, does not recognize

  • and how you’re doing the loguin? ...where senha= ????

  • Make sure you’re comparing md5 to md5, not md5 password.

  • $password = MD5($_POST['password']);

  • Then I have to see with the guy who has the source code, because I don’t change it.

Show 7 more comments

1 answer

0

Without the table creation script there is no way to know how many characters the "password" column supports, but the error indicates that the value being assigned to the field has a larger number of characters than it accepts. Check how many characters your hash is generating and, if so, increase the number of characters in the field so that it can store the returned value.

  • I increased to varchar(100) and it changes, but at the time of I do the loguin, does not recognize

  • But what about the update? It worked and stopped giving the error that was asked?

  • Update worked, only the password was not changed to what I put

  • You can post a better example of this?

  • Then I have to see with the guy who has the source code, because I do not change it. I only make changes in the bank

  • I understand. If my answer helped you I am happy, and when I get the source about the other problem post it in a new question.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.