Book not updated:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法错误;查看与MySQL服务器版本对应的手册,以获得正确的语法,以便在“Linux命令,编辑器和Shell编程实用指南,bookYear = 2010”第1行附近使用
任何人都可以帮助我解决我的错误吗?
这是我的php:
<?php
// Retrieve variables
$bookISBN = filter_has_var(INPUT_GET, 'bookISBN') ? $_GET['bookISBN'] :
null;
$catDesc = filter_has_var(INPUT_GET, 'catDesc') ? $_GET['catDesc'] :
null;
$bookYear = filter_has_var(INPUT_GET, 'bookYear') ? $_GET['bookYear'] :
null;
$bookPrice = filter_has_var(INPUT_GET, 'bookPrice') ? $_GET['bookPrice']
: null;
$bookTitle = filter_has_var(INPUT_GET, 'bookTitle') ? $_GET['bookTitle']
: null;
$errors = false;
if (empty($bookTitle)) {
echo "<p>Book title cannot be empty</p>\n";
$errors = true;
}
if (empty($catDesc)) {
echo "<p>Category cannot be empty</p>\n";
$errors = true;
}
if (empty($bookYear)) {
echo "<p>Book Year cannot be empty</p>\n";
$errors = true;
}
if (empty($bookPrice)) {
echo "<p>Book price cannot be empty.</p>\n";
$errors = true;
}
if ($errors === true) {
echo "<p>Please try <a href='chooseMovieList2.php'>again</a>. </p>\n";
}
else {
try {
require_once("functions.php");
$dbConn = getConnection();
$updateSQL = "UPDATE nbc_books SET catID=$catDesc,
bookTitle=$bookTitle, bookYear=$bookYear, bookPrice=$bookPrice WHERE
bookISBN = $bookISBN";
$dbConn->exec($updateSQL);
echo "<p>Book updated</p>\n";
} catch (Exception $e) {
echo "<p>Book not updated: " . $e->getMessage() . "</p>\n";
}
}
?>