0

Hello im having a bit of a problem, look at this:

SELECT id, activate_key FROM accounts
WHERE id = $accNum 
AND password = '$password' AND activate_key = NULL
// Success! the id and password matched and the activate_key field is null

This is my login. As Soon as I add AND activate_key = NULL you cant login on any account, even if the activate_key field is NULL.

Sorry for the title, as im not a sql guru i couldnt think of a better title explaining my problem

Yuri
  • 3
  • 1
  • 1
    Also should not be [storing passwords in plain text](http://stackoverflow.com/questions/1193697/storing-password-in-databases-in-plain-text-vs-customer-needs). – awm Feb 12 '11 at 15:20

2 Answers2

6

Use IS NULL. = won't work with NULL.

[edit]

Don't forget to escape your password! Your query will fail and can potentially harm your database if you don't.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210
0

Try

activate_key IS NULL

instead of

activate_key = NULL 
Roger
  • 1,004
  • 2
  • 12
  • 24