当我以我制作的表单运行数据库查询时,出现以下错误。
数据库查询失败 1064:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在 'release = "2013-05-27 19:33:29",platform = "PC",description = "Physics Puzzle Ga' 在第 1 行查询附近使用正确的语法: 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" 其中 id=1
我的代码发布在下面,我无法弄清楚语法中的错误在哪里。任何帮助将不胜感激。谢谢!
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);