与服务器的远程连接失败

时间:2019-04-03 09:46:30

标签: mysql

我要连接到在线托管的服务器。

我的代码连接到本地主机,但是当我将值更改为托管服务器时,它给我一个错误

  

警告:mysqli_connect():(HY000 / 2002):由于目标计算机主动拒绝连接,因此无法建立连接。

<?php

$servername = "zamokuhleWeb.co.za";
$username = "*****";
$password = "****";

// Create connection
$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";

?>

我想访问数据库并从中获取某些信息

1 个答案:

答案 0 :(得分:-2)

<?php

$servername = "localhost";
$username = "*****";
$password = "****";

// Create connection
$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";

?>