2016-05-13 160 views
0

我要讓連接到我的在線數據庫,但後來我得到這個錯誤:我想連接我的:在線MySQL數據庫,但我得到這個錯誤。有人能幫我嗎?

Warning: mysqli :: mysqli(): (HY000/2002): A connection attempt failed because the " Related party Incorrectly If the answer after a certain time , of the costs Connection failed because " the Confederate host has not responded . C: \ wamp \ www \ array Add in db \ 222.php on line 8

這是我的代碼:

?php 

$servername = "db.tapdeleest.nl"; $username = "***"; $password = "***"; $dbname = "***"; 
// Create connection 
$conn = new mysqli($servername, $username, $password, $dbname); 
// Check connection 
if ($conn->connect_error) { 
die("Connection failed: " . $conn->connect_error); 
} 
else 
{ 
echo "nice"; 
} 

?> 

感謝您的幫助!

+0

對不起,我的意思是php。 – sander

+0

您能否刪除不喜歡的內容? – sander

+0

你是否遠程連接?如果是,請檢查是否啓用了遠程連接。 –

回答

0

使用新的mysqli(),您不會在連接中添加數據庫名稱。

您使用mysqli_select_db($康恩,$ DBNAME)

<?php 

$servername = "db.tapdeleest.nl"; $username = "***"; $password = "***"; $dbname = "***"; 
// Create connection 
$conn = new mysqli($servername, $username, $password); 
// Check connection 
if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 
else 
{ 
    echo "nice"; 
    mysqli_select_db($conn, $dbname); 
} 

?> 

只是建議:給PDO一試,我覺得PDO更容易。 http://www.w3schools.com/php/php_mysql_connect.asp

+0

它不工作,它不關心,如果你輸入你的:dbname到:$ conn。 – sander

相關問題