代碼:您的SQL語法有錯誤;檢查對應於你的MySQL服務器版本正確的語法使用手動附近的視角
$sql = "
INSERT INTO book
(id
, account_no
, admin_id
, title
, author
, edition
, book_publisher
, book_copies
, book_isbn
, print_place
, book_year
, book_pages
, book_price
, entry_date
) VALUES
(''
, '$account_id'
, '$admin_id'
, '$title'
, '$author'
, '$edition'
, '$publisher'
, '$copies'
, '$isbn'
, '$place'
, '$year'
, '$pages'
, '$price'
, '$date'
)
";
在使用此查詢我收到此錯誤插入數據:
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 's Perspective','Randal E. Bryant','2','Prentice Hall','2','978-0136108047','USA'' at line 3
任何人都可以告訴如何解決這個錯誤?
注射攻擊仍然發生,你有危險 – 2014-10-08 08:20:00
顯然有一些v就像'Someone's Perspective'那樣會破壞查詢。使用PDO,預處理語句,轉義數據等。 – 2014-10-08 08:21:46
您確定ID列未在數據庫中設置爲auto_increment嗎?如果是,則從表格和值列表中排除。 – 2014-10-08 08:22:45