这是我的代码,在收到的消息下方。
<?php
$con = mysqli_connect('127.0.0.1', 'root', 'root');
if (mysqli_connect_error()) {
die('Connect Error ('.mysqli_connect_errno().') '.mysqli_connect_error());
}
echo 'Connected successfully.';
if(!$con) {
echo "not connected to server";
}
if(!mysqli_select_db('$con', 'tutorial')) {
echo('Connection Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
$Name = $_POST['username'];
$Email = $_POST['email'];
$sql = "INSERT INTO person (Name, Email) VALUES ('', $Name', '$Email')";
if(!mysqli_query($con, $sql)) {
echo "not inserted" . mysqli_error();
}
else {
echo "inserted";
}?>
这是我收到的消息
连接成功。未插入连接错误(0)