Php 查询失败。更新时,SQL语法有错误
所以,在一个学校项目中工作,我试图创建一种方法来更新页面上的现有产品,只更新我想要更新的价格和描述。我只是不知道我哪里出了问题。提前谢谢 现在,在Php 查询失败。更新时,SQL语法有错误,php,mysql,Php,Mysql,所以,在一个学校项目中工作,我试图创建一种方法来更新页面上的现有产品,只更新我想要更新的价格和描述。我只是不知道我哪里出了问题。提前谢谢 现在,在update.php页面上,我创建了一个函数,以便它以选项选择形式动态显示产品 这是一个错误 查询失败您的SQL语法有错误;检查手册 对应于MySQL服务器版本的正确语法 在第1行使用“WHERE product=SAMSUNG 60”全高清四核3D智能液晶LED电视” 这是我的更新功能 函数updateData(){ 这是我的update.php页面
update.php
页面上,我创建了一个函数,以便它以选项选择形式动态显示产品
这是一个错误
查询失败您的SQL语法有错误;检查手册
对应于MySQL服务器版本的正确语法
在第1行使用“WHERE product=SAMSUNG 60”全高清四核3D智能液晶LED电视
”
这是我的更新功能
函数updateData(){
这是我的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>
require_once(“Includes/simplecms config.php”);
需要一次(“Includes/connectDB.php”);
include(“Includes/header.php”);
包括(“functionsphp.php”);
确认_是_admin();
更新数据();
//html上载表单的最大文件大小
$max\u file\u size=50*1024*1024;//大小(字节)
//将接收上载文件的目录
$dir='图像/产品/';
?>
更新产品
填写下面的详细信息以将详细信息更新到
目录项
更新产品
请填写以下详细信息,将产品更新为
目录
价格
描述
现在请参阅关于准备好的和绑定的查询。正如前面提到的,where子句应该引用主键这是一个简单的输入错误where about?逗号、引号和反勾号都应该谨慎使用
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>
$query = "
UPDATE products
SET price = $itemprice
, description = '$itemDescription'
WHERE product = '$itemName'
";