开发者

bind_param error

开发者 https://www.devze.com 2023-03-20 14:36 出处:网络
This is my Error: Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn\'t match number of parameters in prepared statement in /Applications/XAMPP/xamppfiles/htdo

This is my Error:

Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement in /Applications/XAMPP/xamppfiles/htdocs/Jil/benutzer_eintragen.php on line 19

and this is my Code

$sql = "INSERT INTO benut开发者_开发技巧zer SET vorname='?', nachname='?', username='?', email='?', passwort='?';";
$stmt = $db->prepare($sql);
$stmt->bind_param("sssss", $vorname, $nachname, $username, $email, $passwort);
$stmt->execute();


I think you need to eliminate the quote marks in the statement:

$sql = "INSERT INTO benutzer SET vorname=?, nachname=?, username=?, email=?, passwort=?;";


You don't need the quotes around the ? in the SQL statement.

Also, your SQL statement is incorrect. SET is only used with UPDATE, INSERT uses VALUES.

$sql = "INSERT INTO benutzer(vorname,nachname,username,email,passwort) VALUES (?,?,?,?,?)";

$sql = "INSERT INTO benutzer SET vorname=?, nachname=?, username=?, email=?, passwort=?";
$stmt = $db->prepare($sql);
$stmt->bind_param("sssss", $vorname, $nachname, $username, $email, $passwort);
$stmt->execute();
0

精彩评论

暂无评论...
验证码 换一张
取 消