php数据库连接错误HTTP错误500

时间:2017-09-18 10:23:20

标签: php html database mysqli

尝试连接到服务器上已创建的数据库并在我尝试运行它时显示其内容页面显示错误,指出HTTP 500错误,该站点可能正在维护或可能有编程错误。

<?php
ini_set("display_errors",1);
error_reporting(E_ALL);

这些都有价值,只是隐藏它们 当我通过PHP代码检查器运行代码时,它有一个问题&#39; {&#39;在下面的线上

$servername = "servername";
$username = "username";
$password = "password";
$dbname = "dbname";

// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection

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

$result = mysql_query("SELECT * FROM Pictures ");
$conn->close();
?>

用于显示数据库的HTML

<html>

 <table border="2" style= "background-color: #84ed86; color: #761a9b; margin: 0 auto;" >
  <thead>
    <tr>
      <th>id</th>
      <th>Name</th>
      <th>image</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
  <?php
  while( $row1 = mysqli_fetch_assoc( $result ) ){
    foreach ($row1 as $row){
 ?>
    <tr>
      <td><?php $row['id'] ?></td>
      <td><?php $row['hname'] ?></td>
      <td><?php $row['himage'] ?></td>
      <td><?php $row['hdesc'] ?></td> 
    </tr>
 <?php
    }
  }
  ?>
  </tbody>
</table>
 <?php mysql_close($connector); ?>
</body>


 </html>

0 个答案:

没有答案