我要连接到在线托管的服务器。
我的代码连接到本地主机,但是当我将值更改为托管服务器时,它给我一个错误
警告: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";
?>
我想访问数据库并从中获取某些信息
答案 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";
?>