简体   繁体   中英

(HY000/2005): Unknown MySQL server host 'fdb32.awardspace.net:3306' (-2) Connection failed: Unknown MySQL server host 'fdb32.awardspace.net:3306' (-2)

Hi all I a new to sql so I apologise in advance. My link is http://suteki.atwebpages.com/test.php and the error I keep getting is

Warning: mysqli::__construct(): (HY000/2005): Unknown MySQL server host 'fdb32.awardspace.net:3306' (-2) in /srv/disk20/4134947/www/suteki.atwebpages.com/connect.php on line 8. Connection failed: Unknown MySQL server host 'fdb32.awardspace.net:3306' (-2)

I am using awardspace and I have all the details correct for port and host db name etc. but this is driving me up the wall. I have searched online and every other similar error found does not relate to my problem. My connect.php is as posted below:

><?php
>$servername = "fdb32.awardspace.net:3306";
>$username = "4134947_suteki";
>$password = "m;4bSu+p4!}Sn/o9";
>$dbname = "4134947_suteki";

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

My test.php is as follows:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="description" content="This is a Japanese Restaurant website">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@600&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@300&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="main.css">
    <link rel="icon" href="https://stpierres.co.nz/images/20190329151614.png"/>
    <title>素てきSuteki Test</title>
    <style>
    .orderHere {
        display: inline-block;
        width: 70%
}


     #orderH {
        display:flex;
        flex-direction: row;
        flex-wrap: wrap;
}
        </style>  
  </head>
 
 <body style="background-color:black";>
  
    <div class="box banner">
      <h1><a href="index.php">素 て き</a></h1>
    </div>


    <!-- navigation -->
    <div class="box nav">
      <a href="index.php">HOMEPAGE</a>
      <a href="menu.php">MENU</a>
      <a href="order.php">ORDER</a>
      <a href="contactus.php">CONTACT US</a>
      <a href="test.php">TEST</a>
    </div>

   
    <!--main content-->
    
    <div class="content">
       
    <h1>Database</h1>
    
      <?php 
      
              require_once 'connect.php';
              
              $sql = "SELECT menu.*, order_total.* FROM menu, order_total WHERE menu.menu_id = order_total.menu_id";
              
              $result = $conn->query($sql);
              
              echo '<h1 class="orderHere">Order Here</h1>';
              
              echo '<section id="orderH">';
              
                      if($result->num_rows > 0){ 
                              while($row = $result->fetch_assoc()){
                                      echo '<article>';
                                      
                                              echo '<h2>' . $row["Title"] . '</h2>';
                                              
                                              echo '<figure><img src=' . $row["Image"] . ' height="150" width="150"> </figure>';
                                              
                                              echo '<p><span id="title">Menu Item: </span><span>'. $row["item_title"] . '</span></p>';
                                              echo '<p><span id="title">Description: </span><span>'. $row["description"] . '</span></p>';
                                              echo '<p><span id="title">Menu Item: </span><span>'. $row["item_title"] . '</span></p>';                                 
                                              echo '<p><span id="title">Price: </span><span>'. number_format((float)$row["price"], 2, '.', '') . '</span></p>';
                                      
                                      echo '</article>';
                              }
                        }
               echo '</section>';
              
      ?>
      
</div>
  </body>

Any help would be greatly appreciated - thank you kindly.

Its the same person (cinnamon). I forgot my log in details.

Anyway, thanks so much for your assistance. I have changed my connect.php accordingly, however its still not playing nice

connect_error) { die("Connection failed: ". $conn->connect_error); }?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM