Under what conditions do I need to single quote a variable in a Mysql statement in PHP?
Share
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.
If you put values directly in the query, as in
SELECT * FROM users WHERE age > 25, then the single quotes are used only with strings. If you writeSELECT * FROM users WHERE age > '25', the query works the same, but you are forcing MySQL to convert the string to an integer (if that field is an integer), which is a not necessary operation.