![](/img/trans.png)
[英]Check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id ='2'' at line 4
[英]check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id=' \r\n
我是php新手,無法使用它! 我正在嘗試編輯頁面上的數據,該頁面將通過更新頁面存儲到mySQL上。
<?php
include("secure/connect.php");
$newtitle = mysqli_real_escape_string($conn, ($_POST['title']));
$newinfo = mysqli_real_escape_string($conn,($_POST['info']));
$newprice = mysqli_real_escape_string($conn,($_POST['price']));
$newmenu_img = mysqli_real_escape_string($conn,($_POST['menu_img']));
$id = mysqli_real_escape_string($conn, ($_POST['rowid']));
//setup a SQL query
$query= "UPDATE cocktails SET title='$newtitle', info='$newinfo', price='$newprice', menu_img='$newmenu_img', WHERE id='$id'";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
mysqli_close($conn);
?>
我不斷收到錯誤消息:您的SQL語法有錯誤; 檢查與您的MariaDB服務器版本相對應的手冊以獲取正確的語法以在'WHERE id ='\\ r \\ n附近使用注意:未定義的變量:/ var / www / vh中的iddata在第1行
如果您的參數確定,請在此行中刪除逗號(,)
UPDATE cocktails SET title='$newtitle', info='$newinfo', price='$newprice', menu_img='$newmenu_img', WHERE id='$id'
在此之前, WHERE
會做。 請注意,MariaDB將從錯誤消息的確切位置開始在錯誤消息中啟動代碼-在您的情況下,它將嘗試將WHERE
部分解析為參數列表的延續。
您的代碼也容易受到SQL代碼注入的影響,因此在將代碼發送到生產服務器之前,請先查看此答案 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.