-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