未能将任何值插入我的mysql数据库。 建立与数据库的连接,但不能插入任何值。此外,由于某种原因“mysqli_error($ connection)”没有输出任何错误。 PHP部分代码如下。请帮忙 !
<?php
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$connection = mysql_connect('localhost:8889', 'root', 'root','loginapp');
if($connection) {
echo "We are connected";
} else {
die("Database connection failed!");
}
$query = "INSERT INTO users(username,password) ";
$query .="VALUES ('$username', '$password')";
$result = mysqli_query($connection, $query);
if(!$result) {
die("QUERY FAILED ." . mysqli_error($connection));
}else {
echo 'You can not leave any field blank';
}
}
?>