无法使用000webhost连接到数据库 [英] Can't connect to database with 000webhost

查看:44
本文介绍了无法使用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.

警告:mysqli :: mysqli()[mysqli.mysqli]:(28000/1045):访问被拒绝 对于用户'a7976620_db1user'@'localhost'(使用密码:是) /home/a7976620/public_html/index.php,第17行

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

这是我的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:

  1. 修复所有权和
  2. 修复文件权限

您可以应用它,这会很好的.

You can apply this and it will be fine.

这篇关于无法使用000webhost连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆