如何删除警告:mysqli_connect():( HY000 / 2002)?

时间:2017-07-25 11:34:14

标签: php html wordpress mysqli database-connection

  

警告:mysqli_connect():( HY000 / 2002):连接尝试失败   因为关联方在一段时间后没有正确回应   时间或已建立的连接因连接的主机而失败   未能回应。在第2行的C:\ xampp \ htdocs \ PHPFiles \ phpfile.php

我的代码没问题... PHP连接到本地主机但不是远程服务器...远程数据库在xamp上我认为

Microsoft Windows 10

<?php
 $con=mysqli_connect("192.168.1.1","cykiqdbuser","pass","cykiqdb");
 // Check connection
 if (mysqli_connect_errno())
 {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }

 $result = mysqli_query($con,"SELECT * FROM cy_bikes_log");

 echo "<table border='1'>
  <tr>
    <th>ID</th>
    <th>Dock ID</th>
    <th>Status</th>
   </tr>";

while($row = mysqli_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['dock_id'] . "</td>";
  echo "<td>" . $row['status'] . "</td>";
  echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>

我可以登录PHP我的管理员在线是否意味着我的数据库在线?

I can login here does this mean my database is online??

1 个答案:

答案 0 :(得分:-1)

检查您的数据库详细信息,因为您在连接中输入了正确的详细信息 $connection = mysqli_connect($mysqlServer, $mysqlUser, $mysqlPass, $mysqlDb);