我尝试使用mysqli
以便在我的数据库中插入数据。但不起作用。错误可能在哪里?
$myDb = new mysqli($hostname, $username, $password, $database);
if($myDb->connect_errno > 0){
die('Unable to connect to database [' . $myDb->connect_error . ']');
}
$statment = $myDb->prepare("INSERT INTO user(name,surname,age)
VALUES (?,?,?)");
$statement->bind_param('s', $_POST['name']);
$statement->bind_param('s', $_POST['surname']);
$statement->bind_param('i', 25);
$statement->execute();
$statement->free_result();
编辑:
我收到此错误:
Binding parameters failed: (0) Execute failed: (2031) No data supplied for parameters in prepared statement