我的更新查询未执行。我检查了狗表中的所有字段标题,它们与我在查询中输入的字段标题相匹配。
在添加dogImage字段之前,它工作正常。但是,我希望用户也能够更新狗图像。 dogImageUpload.php文件对使用文件输入类型上传的图像运行检查,然后将其添加到uploads文件夹中。
请帮忙。顺便说一下这是我的第一个堆栈溢出帖子,所以请原谅任何错误或缺乏解释我的代码的能力。
<?php
session_start();
if(!isset($_SESSION['staffID'])){
Header("Location:../../html/vetLoginForm.html");
die();
}
$id = $_POST['id'];
$newName = $_POST['newName'];
$newBreed = $_POST['newBreed'];
$newGender = $_POST['newGender'];
$newDC = $_POST['newDC'];
$newHeight = $_POST['newHeight'];
$newWeight = $_POST['newWeight'];
$newGenDesc = $_POST['newGenDesc'];
$newDF = $_POST['newDF'];
$newStatus = $_POST['newStatus'];
//connect to db
require('../../services/connection.php');
//file that uploads image to folder in the directory
include("dogImgUpload.php");
//run update query
if($updateDog = mysqli_prepare($con, "UPDATE dog SET
name =?,
breed =?,
gender =?,
dominantColour =?,
height =?,
weight =?,
generalDescription =?,
dateFound =?,
dogImage =?,
status =?,
WHERE dogID =?")){
mysqli_stmt_bind_param($updateDog,"ssssddssssi", $newName, $newBreed, $newGender, $newDC, $newHeight, $newWeight, $newGenDesc, $newDF, $imgFileName, $newStatus, $id);
mysqli_stmt_execute($updateDog);
mysqli_stmt_close($updateDog);
include("updateSuccessful.php");
mysqli_error($con);
}else{
echo "Error updating record" . mysqli_error($con);
}
?>
答案 0 :(得分:0)
在设置列的末尾有一个额外的逗号(删除它)
if($updateDog = mysqli_prepare($con, "UPDATE dog SET
name =?,
breed =?,
gender =?,
dominantColour =?,
height =?,
weight =?,
generalDescription =?,
dateFound =?,
dogImage =?,
status =?
WHERE dogID =?")){
答案 1 :(得分:0)
mysqli_stmt_bind_param($updateDog,"ssssddssssi",
我将要插入状态列的值的数据类型作为字符串。但是,我的数据库中的status列带有int数据类型。