Can't connect to database with 000webhost

孤街浪徒 提交于 2020-01-04 04:06:07

问题


I'm trying to learn php but when I attempt to connect to a mysql database, I get this error. I don't think anything is wrong with the code itself but perhaps there is an error on the hosts side? I'm using 000webhost so.

Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'a7976620_db1user'@'localhost' (using password: YES) in /home/a7976620/public_html/index.php on line 17

Here is my php:

<?php

$servername = "localhost";
$username = "a7976620_db1user";
$password = "******";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?> 

回答1:


In https://www.000webhost.com, there are two options in the cPanel:

  1. Fix ownership and
  2. Fix file permissions

You can apply this and it will be fine.



来源:https://stackoverflow.com/questions/33295846/cant-connect-to-database-with-000webhost

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!