执行此功能向数据库添加数据时出错

时间:2019-05-03 10:59:13

标签: php sql

当我执行命令时,浏览器会显示以下内容:

Fatal error: Uncaught exception 'Exception' in /volume1/web/phpMyAdmin/kalkomservice/secure/access.php:105 Stack trace: #0 /volume1/web/phpMyAdmin/kalkomservice/register.php(51): access->insertUser('tofi048@icloud....', 'Kristóf', 'Kalmár', 'ec7491b5ada4e5d...', '\xE7\xFBl\xF0\xA6CP\xBA\x01\xA93\xCFM\x83>...') #1 {main} thrown in /volume1/web/phpMyAdmin/kalkomservice/secure/access.php on line 105

这是我输入的网址:

http://192.168.1.106/phpMyAdmin/kalkomservice/register.php?email=tofi048@icloud.com&firstName=Krist%C3%B3f&lastName=Kalm%C3%A1r&password=Tofika2004

出什么问题了?

编辑:这是功能:

    public function insertUser($email, $firstName, $lastName, $encryptedPassword, $salt)
{
    //SQL language - command to insert data
    $sql = $this->conn->prepare("INSERT INTO users (email, firstName, lastName, password, salt) VALUES (:email, :firstName, :lastName, :password, :salt)");

    //preparing SQL for execution by checking the validity
    //$statement = $this->conn->prepare($sql);

    //if error
    if (!$sql)
    {
        throw new Exception(($sql->error));
    }


    //assigning variables instead of '?', after checking the preparation and validity of the SQL command
    $sql->bind_param(email, $email);
    $sql->bind_param(firstName, $firstName);
    $sql->bind_param(lastName, $lastName);
    $sql->bind_param(password, $encryptedPassword);
    $sql->bind_param(salt, $salt);


    //result will store the status/result of the execution of SQL command
    $result = $sql->execute();

    return $result;
}

0 个答案:

没有答案