-1
我有一个名为post_data的表,因为我想根据会话变量更新列。如何使用php pdo中的会话变量更新表?
这是我的查询。
$id = $_SESSION['userSession'];
$stmt = $user_home->runQuery("UPDATE post_data
set
cam_name='$cname',
cam_model ='$model',
cam_rent='$rent',
cam_img='$upic',
mobile='$umob'
upd_date='$jdate'
where userID='$id'
");
$stmt->bindParam(':cname',$camname);
$stmt->bindParam(':model',$modelname);
$stmt->bindParam(':rent',$rentpday);
$stmt->bindParam(':upic',$userpic);
$stmt->bindParam(':umob',$usermob);
$stmt->bindParam(":jdate",$upd_date);
if($stmt->execute())
{
$successMSG = "Record saved success";
}
else
{
$errMSG = "error while inserting....";
}
这是runQuery()用户类实现
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
我有错误这样
致命错误:未捕获PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064你的SQL语法有错误;检查对应于您的MariaDB服务器版本的手册,以找到在'upd_date ='附近使用的正确语法2017-09-24 21:29:18'where'在C:\ xampp \ htdocs \ DSLR_proj \ profile.php中的第8行:97
感谢它的工作原理...非常感谢 –
雅非常感谢@Ravi其现在的工作 –
@lohithkumar你需要接受的答案 – Ravi