我有一个php错误。使用php mysqli insert query我不插入数据。 这是我的代码。请告诉我代码中的错误。
if(isset($_POST['ok'])){
$uid = "root";
$pass = "";
$host = "localhost";
$db_name = "amoz";
// Establish Connection
$conn = mysqli_connect($host, $uid, $pass);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}else{
echo "Connected successfully";
echo "<br/>";
}
$first_name = $_POST['first_name_input'];
$middle_name = $_POST['middle_name_input'];
mysqli_query($conn, "INSERT INTO g_$51 (f_name,m_name) VALUES ($first_name,$middle_name)");
}
答案 0 :(得分:0)
缺少要插入的文字的引号 - 试试这个:
mysqli_query($conn, "INSERT INTO g_$51 (f_name,m_name) VALUES ('$first_name','$middle_name')");