未更新个人资料...。代码有什么问题?

时间:2019-06-28 02:01:29

标签: php mysqli

<?php
include '../Config/config1.php';
include '../Config/config.php';
include '../Config/connect.php';
 $IDUser = ($_POST["IDUser"]);
 $Names = ($_POST["Names"]);
 $Address = ($_POST["Address"]);
 $Email = ($_POST["Email"]);
 $Role = ($_POST["Role"]);
 $Activate = ($_POST["Activate"]);
$query2= $dbo->query("UPDATE user SET 
Names='$Names', Address='$Address',Email='$Email' 
,Role='$Role',Activate='$Activate' WHERE userid='$IDUser'");
                    if($query2){
     echo "<script>alert('Profile Updated')</script>";
     echo "<script>location.href='../UserProfile.php? 
id=$IDUser'</script>";
 }else{
     echo "<script>alert('No Profile Updated')</script>";
     echo "<script>location.href='../UserProfile.php? 
id=$IDUser'</script>";
}
    ?>

1 个答案:

答案 0 :(得分:0)

在使用变量的值中使用双引号,并始终尝试使用``作为列名。这是一个例子。

$query2= $dbo->query('UPDATE user SET `Names`="$Names" WHERE `userid`="$IDUser"');

还要确保在查询之前已创建$ dbo对象