php mysqli_connect连接错误(0尝试使用MAMP连接到本地主机数据库

时间:2018-10-18 17:35:50

标签: php mamp

这是我的代码,在收到的消息下方。

<?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)

0 个答案:

没有答案