0
$con = mysqli_connect('localhost', 'root','', 'dbname');
if(filter_input(INPUT_POST, "register")){
$username = filter_input(INPUT_POST,'username');
$password = filter_input(INPUT_POST,'password');
$email = filter_input(INPUT_POST,'email');

$stmtInsertUser = $con -> prepare("INSERT INTO tbl_users (username, password, email) values (?, ?, ?)");

$stmtInsertUser -> bind_param($username, $password, $email);

$stmtInsertUser -> execute();

}

This is my code and it returns this error

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in C:\xampp\htdocs\xxx\xxx\PHPregister.php on line 10

Thanks!

1

2 Answers 2

1

The first parameter of bind_param is a list of what types of inputs are coming in

Per the manual: http://www.php.net/manual/en/mysqli-stmt.bind-param.php (s is string)

$stmtInsertUser -> bind_param('sss',$username, $password, $email);
Sign up to request clarification or add additional context in comments.

1 Comment

Yes it does, the full list: i corresponding variable has type integer, d corresponding variable has type double, s corresponding variable has type string, b corresponding variable is a blob and will be sent in packets
1

Try

$stmtInsertUser->bind_param('sss',$username, $password, $email);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.