2017-07-18 41 views
-2

我有一个php文件,我知道有一个地方的错误。当使用xampp在我的本地机器上使用它时,它工作正常,但是当上传到主机时,我得到标题和导航,然后它说'出错',从我的php代码的检查连接部分,并且不会制作桌子。其他页面工作正常,并提交给数据库,所以我假设connect.php页面是正确的,它的代码是错的。我也已经告诉我的演讲,这是代码,但我在努力寻找问题php html在xampp上本地工作,但没有上传时

<?php 
     //uses the connect.php file to connect to the database 
     include('connect.php') 

?> 

<!DOCTYPE html> 
    <html> 
     <head> 
      <title>Extract data from DB </title> 

      <link rel="stylesheet" type="text/css" href="gcards.css"> 

     </head> 

     <body> 


     <nav class="nav"> 
      <h1>Gcards </h1> 
      <a href="get.php">Gcards</a> 
      <a href="insert.php">INSERT</a> 
      <a href="delete.php">DELETE</a> 
     </nav> 

<?php 

    //query the database to extract relavent data 
    $get= "SELECT * FROM manufacturer 
        join 
     rating on manufacturer.manufacturerID = Rating.RatingID 
        join 
     model on manufacturer.manufacturerID = model.ModelID 
        join 
     ram on manufacturer.manufacturerID = ram.RamID 
        join 
     ram_type on manufacturer.manufacturerID = Ram_Type.Ram_TypeID   
        join 
     clock on manufacturer.manufacturerID = clock.ClockID"; 

    // check connection 
    $data = mysqli_query($dbconnect, $get) or die('error getting'); 

     echo "<table class=\"display\">"; 
     echo "<tr><th>ID</th> 
     <th>Image_Url</th> 
     <th>Manufacturer</th> 
     <th>Series</th> 
     <th>Interface</th> 
     <th>Chipset</th> 
     <th>SLI-Cross Fire</th> 
     <th>Ram</th> 
     <th>Ram Type</th> 
     <th>Clock_Speed</th> 
     <th>Boost_Speed</th> 
     <th>OC_Speed</th></tr>"; 


    while ($row = mysqli_fetch_array($data, MYSQLI_ASSOC)) { 
        echo "<tr>"; 
        echo "</td><td>"; 
        echo $row['ManufacturerID']; 
        echo "</td><td>"; 
     ?> 


       <img src ="<?php echo $row['Image_Url']; ?>" 
        height="100" width="125"> 
      <?php     
        echo "<br>"; 
       ?> 
        <img src ="<?php echo $row['Rating']; ?>" width="125"> 
      <?php 
        echo "</td><td>"; 
        echo $row['Manufacturer']; 
        echo "</td><td>"; 
        echo $row['Series']; 
        echo "</td><td>"; 
        echo $row['Interface']; 
        echo "</td><td>"; 
        echo $row['Chipset']; 
        echo"</td><td>"; 
        echo $row['SLI_Crossfire']; 
        echo"</td><td>"; 
        echo $row['RamNo'];       
        echo "</td><td>"; 
        echo $row['Ram_Type']; 
        echo"</td><td>"; 
        echo $row['Clock_Speed']; 
        echo"</td><td>"; 
        echo $row['Boost_Speed']; 
        echo"</td><td>"; 
        echo $row['OC_Speed']; 
        echo "</td></tr>"; 
        echo "</table>";  
            } 
        ?> 


     </body> 
     </html> 
+2

什么是完整错误? – Daniel

+0

theres没有错误出现它只是不会,显示表时,我直接到网站页面。 $ data = mysqli_query($ dbconnect,$ get)或死('error getting'); – Chris

+2

我必须问:是否更新了凭据以匹配主机身份验证? (而不是仍然设置为您的本地配置?) –

回答

2

看来你可能有你的MySQL(或MariaDB的)从本地XAMPP配置冲突您远程服务器。请注意,出于开发目的,XAMPP MySQL配置比大多数Linux安装中的配置稍微宽松一些。

因此,要找到您的错误,请修改您的代码以输出MySQL错误。

变化$data = mysqli_query($dbconnect, $get) or die('error getting');

if (!$data = mysqli_query($dbconnect, $get)) { 
    printf("Errormessage: %s\n", mysqli_error($dbconnect)); 
    exit; 
} 

这将输出的实际错误的MySQL抛出,并帮助您了解您的SQL内您的问题。它也可能揭示更多。

PHP: mysqli::$error - Manual

+0

谢谢Zach我得到的错误是ErrorMessage: 'on子句'中的未知列'Rating.RatingID' – Chris

+0

您的查询中没有“Rating”表的联接。你有'评级'@Chris –

+0

非常好!所以看来你可能会引用一个拼写错误的列或者一个真正不存在的列。 – Zaky

0

XAMPP通常运行在Windows上,这里是mysql在大多数情况下不区分大小写,这意味着select * from MYTABLE;select * from mytable;是相同的。你的主机可能运行一些unix系统,上面的例子会查询来自不同表的数据。

所以PLZ看看你的查询,即。你有一次表ram_type和更高版本Ram_Type,他们应该被完全写为他们如何定义。

请参阅https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html

相关问题