When I run a database query in a form I made I get the following error.
Database query failed 1064: 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 'release = "2013-05-27 19:33:29",platform = "PC",description = "Physics Puzzle Ga' at line 1 Query: UPDATE games SET title = "Osmos",genre = "Indie",release = "2013-05-27 19:33:29",platform = "PC",description = "Physics Puzzle Game",rating = "7",cost = "9.99" WHERE id=1
My code is posted below, I can't figure out where the error in the syntax is. Any help would be greatly appreciated. Thanks!
if ($id>0) {
$query = 'UPDATE games SET ';
$where = ' WHERE id='.prepareInsert($id);
} else {
$query = 'INSERT INTO games SET ';
$where = '';
}
$query .= 'title = "'.prepareInsert($_REQUEST["title"]).'"';
$query .= ',genre = "'.prepareInsert($_REQUEST["genre"]).'"';
$query .= ',release = "'.prepareInsert($_REQUEST["release"]).'"';
$query .= ',platform = "'.prepareInsert($_REQUEST["platform"]).'"';
$query .= ',description = "'.prepareInsert($_REQUEST["description"]).'"';
$query .= ',rating = "'.prepareInsert($_REQUEST["rating"]).'"';
$query .= ',cost = "'.prepareInsert($_REQUEST["cost"]).'"';
$query .= $where;
// do the query
$result = mysql_query($query)
or die("<p>Database query failed<br>" . mysql_errno() . ": " . mysql_error()."<br>Query: ".$query);