I have the following code:
function GetSetting($key)
{
$Result = mysql_query("SELECT * FROM settings WHERE keys='$key'") or die(mysql_error());
while($Row = mysql_fetch_array($Result))
{
return $Row['value'];
}
return false;
}
But I get the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘keys=’header_title” at line 1
What is wrong with my SQL query?
keysis a reserved word, so you’ll have to escape it:In other words, your query actually isn’t good, and MySQL was telling you exactly where the problem was…