views:

69

answers:

1

Hello

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,$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 :).

Thanks for helping me

+2  A: 

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.

Mike Pelley
i have edit it and i dont get any erros now but it dont insert it to the database :S
Simon
If you don't have an entry in the database, there must be an error. You've checked for an error with the prepare, but not for "$stmt->bind_param" nor "$stmt->execute" (the second one is probably more important). Does either of these return false? If so, $stmt->error should indicate the problem.
Mike Pelley