当我单击按钮时,它表明我的查询已执行。但是,当我检查数据库时,没有任何更改/更新。我已经尝试了许多解决方法,并在此处阅读了许多相关问题并尝试了答案,但没有任何帮助。
这是我的代码:
ob_start();
session_start();
//error_reporting(0);
include_once('config_db.php');
function documentReceived($id){
$updateRece = "UPDATE shipping SET `document_received`='1' WHERE id='".$id."'";
if($GLOBALS['conn']->query($updateRece) == TRUE){
echo 1;
}else{
echo $updateRece;
}
}
function saveRating($rat, $id){
$rating = "UPDATE shipping SET `rating`='".$rat."', `car_received`='1' WHERE id='".$id."'";
if($GLOBALS['conn']->query($rating) == TRUE){
echo 1;
}else{
echo $up;
}
}
if(isset($_POST['action']) && $_POST['action'] == 'documentReceived'){
documentReceived($_POST['id']);
}else if(isset($_POST['action']) && $_POST['action'] == 'saveRating'){
saveRating($_POST['rating'], $_POST['id']);
}
答案 0 :(得分:0)
请尝试更改此内容
function documentReceived($id) {
$updateRece = "UPDATE shipping SET `document_received`='1' WHERE id='" . $id . "'";
if (mysqli_query($GLOBALS['conn'], $updateRece)) {
echo 1;
} else {
echo $updateRece;
}
}
function saveRating($rat, $id) {
$rating = "UPDATE shipping SET `rating`='" . $rat . "', `car_received`='1' WHERE id='" . $id . "'";
if (mysqli_query($GLOBALS['conn'], $rating)) {
echo 1;
} else {
echo $up;
}
}
以上代码中我已更改
if($GLOBALS['conn']->query($updateRece) == TRUE){
到
if (mysqli_query($GLOBALS['conn'], $updateRece)) {