I inserted into user_name and user_password the values zach and sha1('zach'). I then tried to retrieve it with SELECT * FROM user_data WHERE user_name='zach' && user_password=SHA1('zach');

But it shows zero results. When I insert it it shows, but I can't retrieve it. Any ideas?

Recommended Answers

All 5 Replies

How did you insert the record exactly?

Through sql. I tried through php, but qhwn I tried mysqli_num_rows, it kept coming to zero. I tried myphpadmin and the username worked but password did not. I tried multiple times, but it kept acting like this. Idk what is up. I simply INSERT INTO userdata (user_name, user_data) VALUES ('zach', SHA1('zach')); .

I also tried this and it did not work:

SELECT * FROM user_data WHERE user_name='mat' AND user_password=sha1('mat');

Can you show your table structure? If the password column isn't long enough (< 40) then the hashed password gets truncated and can never be retrieved because it won't match anymore.

Turned out it was an error in table types in mysql. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.