-1
因此,在學校項目上工作時,我嘗試創建一種更新頁面上現有產品的方法,但只是要更新的價格和描述。我無法弄清楚我要去哪裏錯了。提前致謝。查詢失敗。更新
現在update.php
頁面上我已經創建了一個功能,使其動態顯示產品中的選項,選擇形式。
這是錯誤,
查詢failedYou在你的SQL語法錯誤;檢查對應於你的MySQL服務器版本正確的語法使用 接近手動 「WHERE產品=
SAMSUNG 60" FULL HD QUAD CORE 3D SMART LCD LED TV
」在1號線
這是我更新功能
功能了updateData(){
if(isset($_POST['submit'])) {
global $db;
$itemName = $_POST['product'];
$itemprice = $_POST['itemPrice'];
$itemDescription = $_POST['itemDescription'];
$query = "UPDATE products SET ";
$query .= " price = `$itemprice`, ";
$query .= " description = `$itemDescription`, ";
$query .= " WHERE product = `$itemName` ";
$result = mysqli_query($db, $query);
if(!$result) {
die("query failed" . mysqli_error($db));
} else {
echo "Your details have been updated";
}
}
}
,這裏是我的update.php頁
require_once ("Includes/simplecms-config.php");
require_once ("Includes/connectDB.php");
include("Includes/header.php");
include("functionsphp.php");
confirm_is_admin();
updateData();
// max file size for the html upload form
$max_file_size = 50 * 1024 * 1024; // size in bytes
// directory that will recieve the uploaded file
$dir = 'Images/products/';
?>
<div id="container">
<div id="admin">
<h1>update Product</h1>
<form id="product_form" class="dialogform"
action="editProduct.php" method="post" enctype="multipart/form-
data">
<div class="form_description">
<p>Fill in the details below to update details to the
catalog item.</p>
<select class="description" name="product" id="">
<?php ShowProduct();?>
</select>
</div>
<div id="container">
<div id="admin">
<h1>update Product</h1>
<form id="product_form" class="dialogform"
action="addProduct.php" method="post" enctype="multipart/form-
data">
<div class="form_description">
<p>Fill in the details below to update the product to
the catalog.</p>
</div>
<label class="description" for="itemPrice">Price</label>
<div>
<input id="itemPrice" name="itemPrice" type="text"
maxlength="255" />
</div>
<label class="description"
for="itemDescription">Description</label>
<div>
<textarea style="width: 350px; height: 108px;"
id="itemDescription" name="itemDescription"></textarea>
</div>
<input id="submit_button" class="button_text"
type="submit" name="submit" value="Submit" />
</form>
</div>
</div>
這是一個簡單的拼寫錯誤 –
其中約是什麼呢? –
逗號,引號和反引號都應謹慎使用 – Strawberry