2017-07-29 98 views
-4

无法连接到数据库。 我的错误:在我的代码错误,但我无法找出如何修复

[Sat Jul 29 23:02:56.747139 2017] [proxy_fcgi:error] [pid 13049:tid 140689614522112] [] AH01071: Got error 'PHP message: PHP Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'timavnl_1'@'localhost' (using password: YES) in /home/timavnl/domains/tim-av.nl/public_html/6628/job/db_connect.php on line 2\nPHP message: PHP Warning: mysqli::prepare(): Couldn't fetch mysqli in /home/timavnl/domains/tim-av.nl/public_html/6628/job/index.php on line 5\nPHP message: PHP Warning: main(): Couldn't fetch mysqli in /home/timavnl/domains/tim-av.nl/public_html/6628/job/index.php on line 10\nPHP message: PHP Notice: Trying to get property of non-object in /home/timavnl/domains/tim-av.nl/public_html/6628/job/index.php on line 23\nPHP message: PHP Fatal error: Call to a member function fetch() on null in /home/timavnl/domains/tim-av.nl/public_html/6628/job/index.php on line 24\n'

我的DB连接代码:

<?php 
$db = new mysqli("localhost","timavnl_1","password"."timavnl_1") or 
die("ERROR! With connection"); 
?> 

的index.php代码: Picture of: index.php

+0

的代码是好的,你有问题,数据库凭据。 – kuba

+0

只是你的错误,这个问题是关于你试图创建一个连接到你的数据库 'PHP警告:mysqli :: mysqli():(HY000/1045):拒绝访问用户'timavnl_1'@'localhost'(使用密码:是)在/home/timavnl/domains/tim-av.nl/public_html/6628/job/db_connect.php在线2上 为什么你有这个错误?不知道没有代码,但它与你的凭据有关 – sheplu

+0

这是至少有一打以前的问题在这里重复。请有礼貌地至少对*确切的错误信息做一个基本的搜索(通过Google或本网站)*您将看到在发布新问题之前是否有可用的解决方案。 –

回答

0

你有一个错字错。您设置了密码后给予.,与,改变这一点,这样使用

"<"?php $db = new mysqli("localhost","timavnl_1","password","timavnl_1") or die("ERROR! With connection"); ?> 

正确的语法为使connection对象,参数必须由,运营商sephrated。

语法

$mysqli = new mysqli("localhost", "user", "password", "database"); 

注:根据所使用的connection功能,各种参数可以omitted。如果未提供参数,则该扩展尝试使用在PHP配置文件中设置的默认值。检查手册here

相关问题