[用户以pdo登录后更新查询失败

问题描述 投票:-1回答:1

如果用户登录成功。用户可以更新其帐户信息。但是它显示了一些错误。错误是:

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE `email` = '[email protected]'' at line 1 in C:\xampp\htdocs\kridha\updatevalidation.php:23 Stack trace: #0 C:\xampp\htdocs\kridha\updatevalidation.php(23): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\kridha\updatevalidation.php on line 23

uploadvalidation.php


<?php
 include('database.php');
session_start();


if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $class = $_POST['class'];
    $subject = $_POST['subject'];
    $email = $_SESSION['email'];

    $sql = "UPDATE `student` SET `name` = :name, `class` = :class, `subject` = :subject,  `email` = :email,  WHERE `email` = :email ";



    $statement = $conn->prepare($sql);
    $statement->bindValue(":name", $name);
    $statement->bindValue(":class", $class);
    $statement->bindValue(":subject", $subject);
    $statement->bindValue(":email", $email);

    $count = $statement->execute();

    if ($count>0) {
        echo "<script type='text/javascript'>alert('updation suceesful');
    window.location='accountsettings.hp';
    </script>";
    } else {
        echo "<script type='text/javascript'>alert('error');
    window.location='accountsettings.php';
    </script>";
    }
}

?>

我的代码出了什么问题。我正在使用电子邮件作为会话变量。请帮忙!!!请不要删除此问题,我已经尝试了几个类似的问题,但没有一个对我有帮助!

php pdo
1个回答
-1
投票

使用]测试>

WHERE '.$email.' = :email');

您让我知道进展如何。

© www.soinside.com 2019 - 2024. All rights reserved.