SQL語句報錯:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near


報錯如圖:

最開始其實我的列名tname和tsubject分別叫name和subject,后來看到網上有說這個報錯可能是數據庫建表的時候使用了mysql的關鍵詞,我就只把name改了。后來還是這個問題,百思不得其解。

后來同學告訴我說老師幫她檢查SQL語句的問題時都是把php程序里的SQL語句先復制到mysql里面去執行看是不是數據庫的問題的。

太機智了,我為什么沒想到?復制過去一看,怎么subject也是關鍵詞啊! 很有信心的改掉以后等待正確結果,但是竟然還是這個錯。。。

沒關系,小場面。

后來我又是在數據庫里面各種試,一次誤操作int類型的那列給搞了個字符串然后插入失敗。瞬間恍然大悟。把$age=$_POST['age'];改成了$age=(int)$_POST['age'];。然后果然就成功插入了。。。。  

可是很奇怪,我之前寫php並沒有強制這樣轉換過也插入成功了啊,而且同學也沒有這個操作,難道是版本問題???奇怪。。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 解決:[Err] 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 ERROR 1064 (42000): 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 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 '"id", 報錯--->java.sql.SQLSyntaxErrorException: 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 'delect from testd MySql 執行語句錯誤 Err] 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 【異常】MySQL建表報錯: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 '"order"' at line 1 修改mysql密碼報錯: 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 ' Django進行數據遷移時,報錯:(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 '(6) NOT NULL)' at line 1") mybatis批量更新update-設置多個字段值 報錯 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 php"> [Err] 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 ''

php

 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM