Page 1 of 1

MYSQL client

Posted: Tue Oct 11, 2011 7:49 pm
by jonathon
Hi,

I'm driving myself mad here, I've written a login script which isn't working so I thought I'll go into my PHPmyAdmin and use the client. My email and username return no results using this query:
SELECT id, firstName
FROM users
WHERE (`email` = 'myemail@example.com' AND `password`= '544sd4a5d4as5d4fsd4f') // This a long hash 
The query doesn't fail it just returns no records and i'm using the values already stored in the DB. If i just search for a column that isn't the password column it returns the information. But as soon as I involve the password column in a combination WHERE or on its own it fails. And I'm copying and pasting the value from the database.

What am I dong wrong? :-(

Re: MYSQL client

Posted: Tue Oct 11, 2011 7:52 pm
by jacek
Hmm, it looks okay overall. The only thing I can think of is that id is a mysql keywords, so try wrapping all of the column and table names in backticks. I tend to do this any way just to avoid there being any problems.

Re: MYSQL client

Posted: Tue Oct 11, 2011 8:01 pm
by jonathon
Yeah I did try that, same result. I don't know whether to be pleased that i'm not going mad or disappointed that it isn't just an oversight. I don't see what's wrong with the pword column :S

Re: MYSQL client

Posted: Tue Oct 11, 2011 8:27 pm
by jacek
Maybe try it without the brackets then, since they usually indicate a sub-query
SELECT
    `id`,
    `firstName`
FROM `users`
WHERE `email` = 'myemail@example.com'
AND `password`= '544sd4a5d4as5d4fsd4f'
??

Re: MYSQL client

Posted: Tue Oct 11, 2011 8:32 pm
by jonathon
Hmm, still the same, I'm at a loss.
This is as simple I can make the query and it still fails
SELECT `firstName` FROM `users` WHERE `password` = '544sd4a5d4as5d4fsd4f'

Re: MYSQL client

Posted: Tue Oct 11, 2011 9:06 pm
by jacek
Right, :?

Are you sure the password in the table is the same ? Check to make sure it does not have a space or somethign after it.

Re: MYSQL client

Posted: Wed Oct 12, 2011 9:23 pm
by jonathon
I think it might have been because i'm storing the password in binary so that's why the client didn't return the row when using the password value. Not sure though, thanks for the help.

Re: MYSQL client

Posted: Wed Oct 12, 2011 9:27 pm
by jacek
Oh, not an unsolved topic ! As long as you got it working :D

Re: MYSQL client

Posted: Wed Oct 12, 2011 11:39 pm
by jonathon
Yeah - thanks Jacek :D