简体   繁体   English

通过数据库连接获取连接超时

[英]Getting connection timed out with DB connection

I am trying to connect to a remote rackspace DB PHP:我正在尝试连接到远程机架空间数据库 PHP:

<?php
  $servername = "XX.XX.XX.XX";
   $username = "username";
   $password = "password";
   $dbname = "table";
    // Create connection
       $conn = new mysqli($servername, $username, $password, $dbname);
     // Check connection
       if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
   } 
 ?>

And I get我得到

Warning: mysqli::mysqli(): (HY000/2002): Connection timed out警告:mysqli::mysqli(): (HY000/2002): 连接超时

Try this尝试这个

 <?php
      $servername = "XX.XX.XX.XX";
       $username = "username";
       $password = "password";
       $dbname = "table";
        // Create connection
           $conn = mysqli_connect($servername, $username, $password, $dbname);
         // Check connection
           if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();die();

       } 
     ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接超时-Db-Codeigniter - Connection Timed Out - Db - Codeigniter 检查“连接超时” - Check for a 'Connection timed out' 与mysql的连接超时 - Connection to mysql timed out AsyncTask上的连接超时 - Connection timed out on AsyncTask PHPMailer连接超时 - PHPMailer connection timed out AMQP - 连接超时 - AMQP - connection timed out Beanstalk获取套接字错误110:连接超时 - Beanstalk Getting Socket error 110: Connection timed out Google SMTP连接超时 - Google SMTP connection timed out iframe 横幅: <!--? if connection timed out then</div--><div id="text_translate"><p> 在我的站点中,我使用 iframe 来显示来自其他站点的横幅。 问题是,其他站点的连接很少有问题。 现在偏离了那个“不那么频繁”的时间,空帧会出现,这不好。 我想要的是某种 php if..else 条件语句,可以将其重定向到其他横幅。 也许(逻辑上)它会是这样的:</p><pre> &lt;?php $iframe = the iframe url; $banner = the local banner url; if ($iframe connection timed out) {$banner;}?&gt;</pre><p> 我是一个 100% 的菜鸟,所以请帮助 p</p></div> - iframe banner: <? if connection timed out then 在类扩展上连接超时 - Connection timed out On Class Extend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM