一个字段插入数据库但另一个字段不插入

时间:2017-03-01 07:03:23

标签: php mysql mysqli

我想通过html& mysqli连接在数据库中插入数据。我插入了名称和电子邮件,但是没有添加不幸的名字?

我的php连接代码是(显示12个没有行代码的错误):

 <?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "studendata");

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Escape user inputs for security
$name = mysqli_real_escape_string($link, $_REQUEST['name']);
 $email = mysqli_real_escape_string($link, $_REQUEST['email']);

// attempt insert query execution
$sql = "INSERT INTO person (name,email) VALUES ('$name','$email')";
if(mysqli_query($link, $sql)){
    echo "Records added successfully.";
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// close connection
mysqli_close($link);
?>

任何人都可以说为什么我的名字不插入这里???

截图: whats wrong??

1st 2 inpute were taken directly from database phpmyadmin

我做错了什么????

0 个答案:

没有答案