Code: Select all
<?php
$query = "SELECT hex FROM style WHERE default=1";
$result = mysql_query("$query", $connection);
if(!$result){
die("Database query failed: " . mysql_error());
}
while($row = mysql_fetch_array($result)){
echo $row["hex"] . "<br />";
}
?>
"Database query failed: 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 '=1' at line 1"
Now I understand what the failed message is saying, however I just cant see where Im going wrong with my SQL statement as I've used statements as trivial as this before without problems.
*******************************************************************
Right, now that the above is working I need to extend on it further;
Code: Select all
if ($selected_radio == 'blue') {
$query = "UPDATE style SET default_value = 1 WHERE name='$selected_radio'";
$result = mysql_query("$query", $connection);
if(!$result){die("SQL failed: " . mysql_error());}
I've not done much with SQL before so any insight as to the direction I need to take would be great.