$query = "SELECT * FROM `users` WHERE `username` = 'admin'";#works
$query = "SELECT * FROM 'users' WHERE 'username' = 'admin'";#does not work
Is this yet another quirk Im going to have to get used to, or is something funny going on?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Single quotes (
') and double quotes (") are used to specify strings in MySQL. Backticks (`) are used for column/table references.Your second query will fail for two reasons:
'users'specifies a string, not a reference to the tableusers, andFROMexpects a table reference.'username' = 'admin'does a string comparison, and the stringusernameis never equal to the stringadmin.