My query is throwing up this error. Can anyone see why?
$query = "SELECT * FROM Units WHERE ID = `$uniqueUnits[a]`";
Unknown column ” in ‘where clause’
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.
Two problems.
You’re using backticks to delimit a string. Backticks delimit fields, so MySQL thinks you’re trying to give it a column name.
The error message indicates that, in fact, this value that it thinks is a column name, is empty. So your value
$uniqueUnits[a]is probably broken, or not being interpolated correctly.You should do the following:
Interpolate your variables explictly with the “complex syntax” to be sure that the string forms properly;
Check the value of
$queryso that you can see what’s going on:Use actual quotation marks to delimit strings: