字符串未插入表中

时间:2015-02-15 13:33:01

标签: php mysql insert

我在下面附上了我的php代码,我有一个问题,为什么当我尝试在表中插入一个新用户时查询没有执行?我提到我得到了succes_set,这意味着insert_stmt-> execute()正确运行。

if($_SESSION["err_set"] == 0)
{
    $password = hash('whirlpool', $password);
$password = strtoupper($password);
    $created = date('Y-m-d H:i:s');
    // Insert the new user into the database 
    if($insert_stmt == $db_link->prepare("INSERT INTO users (first_name, last_name, username, email, password, created) VALUES (?, ?, ?, ?, ?, ?)")) 
{
        $insert_stmt->bind_param('ssssss', $first_name, $last_name, $username, $email, $password, $created);
        if (!$insert_stmt->execute()) 
        {
            $_SESSION["err_set"] = 1;
            $_SESSION["err_txt"] = "Unknown error, code: 1301";
            header('Location: ../index.php?page=register&lang='.$language);
        }
    }
    $_SESSION["succes_set"] = 1;
    header('Location: ../index.php?page=login&lang='.$language);
}

1 个答案:

答案 0 :(得分:0)

我解决了这个问题,我删除了其中一个" ="来自

的角色
$insert_stmt == $db_link->prepare("INSERT INTO users (first_name, last_name, username, email, password, created) VALUES (?, ?, ?, ?, ?, ?)")

现在我有了

$insert_stmt = $db_link->prepare("INSERT INTO users (first_name, last_name, username, email, password, created) VALUES (?, ?, ?, ?, ?, ?)")

谢谢你们,伙计们。