本文介绍了无法使用000webhost连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试学习php,但是当我尝试连接到mysql数据库时,出现此错误.我认为代码本身没有任何问题,但是主机方面可能存在错误?我正在使用000webhost.
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.
这是我的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";
?>
推荐答案
在 https://www.000webhost.com ,cPanel中有两个选项:
In https://www.000webhost.com, there are two options in the cPanel:
- 修复所有权和
- 修复文件权限
您可以应用它,这会很好的.
You can apply this and it will be fine.
这篇关于无法使用000webhost连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!