2017-07-29 52 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

相關問題