Warning: mysqli_connect(): (HY000/1045): Access denied for user 'usr'@'localhost' (using password: YES) in /storage/emulated/0/htdocs/includes/condb.php on line 9 Failed to connect to MySql: Access denied for user 'usr'@'localhost' (using password: YES) Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /storage/emulated/0/htdocs/includes/condb.php on line 19
Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /storage/emulated/0/htdocs/includes/condb.php on line 20 Unable to connect
我试图连接到数据库使用这段代码,但都不行。我不知道我到底做错了什么。我试过用谷歌搜索和阅读一些文章,但都没用。
更新的代码仍然得到上面的错误消息。
$server = "127.0.0.1"; $username = "usr"; $password = "123"; $database
= "contents";
$conn = mysqli_connect($server,$username,$password,$database);
if(mysqli_connect_errno($conn)) {
echo "Failed to connect to MySql: ".mysqli_connect_error(); }
$sql = "INSERT INTO contents('subj','article','day') VALUES
('".$_POST['This is the subj']."', '".$_POST['This is the
content']."', '".$_POST['2019-02-01 10:15:59']."')";
if(!mysqli_query($conn,$sql)) {
die("Unable to connect".mysqli_error($conn)); }else {
echo "Connected"; }
?>
不幸的是,仍然遇到相同的错误,这不是一个印刷错误。 至今仍无法解决这个问题。 有解决问题能力的人可以帮助我一下。