mysqli insert query
i have this error:
Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in E:\wamp\www\classes\UserLogin.php on line 31
and i dont know what it is :/
here is my code
function createUser($username, $password) {
$mysql = connect();
if($stmt = $mysql->prepare('INSERT INTO users (username, password, alder, hood, fornavn, efternavn, city, ip, level, email) VALUES (?,?,?,?,?,?,?,?,?,?)')) {
$stmt->bind_param($username,开发者_StackOverflow中文版$password, $alder, $hood, $fornavn, $efternavn, $city, $ip, $level, $email);
$stmt->execute();
$stmt->close();
} else {
echo 'error: ' . $mysql->error;
}
then my user create the user they only need to type username and password, and later they can edit the profile and edit, email,alder,hood and like that :).
I believe your bind_param call should include a type specification string. In your case, perhaps something like this:
$stmt->bind_param('ssssssssis', $username,$password, $alder, $hood,
$fornavn, $efternavn, $city, $ip, $level, $email);
although I'm guessing at your data types. See the mysqli_stmt::bind_param documentation page for more information.
精彩评论