<?php
$servername = "localhost";
$username = "root";
$password = "";
$databasename = "test";
$conn = new mysqli($servername , $username , $password, $databasename);
$name = $_POST["firstname"];
$last = $_POST["lastname"];
$statement = mysqli_prepare($conn, "INSERT INTO user(firstname ,lastname) VALUES(?,?)");
mysqli_stmt_bind_param($statement ,"si", $name,$last);
mysqli_stmt_execute($statement);
$response = array();
$response["success"] = true;
echo json_encode($response);
?>
上面的php脚本中存在的问题是它在数据库中保存名字而无法保存姓氏。
答案 0 :(得分:0)
问题在于这条线,
mysqli_stmt_bind_param($statement ,"si", $name,$last);
^ see here
应该是,
mysqli_stmt_bind_param($statement ,"ss", $name,$last);