为什么我的PHP代码没有显示在我的Web浏览器中?它只是一个空白的白页

时间:2017-06-07 06:59:11

标签: php database

所以我试图连接到我的数据库并在网页上显示车辆。然而,它只是提出一个空白页面,而不显示任何内容。

以下是我从我的数据库中显示车辆内容的页面代码

任何想法?

<?php
   $conn = @mysqli_connect("localhost", "root", "2401", "taylor_callaghan_wca");

$query = "SELECT * FROM vehicle";
$results = mysqli_query($conn, $query);
if(!$results) {
echo ("Query error: " . mysqli_error($conn));
}

else {
// Fetch and display the results of the select query
while ($row = mysqli_fetch_array($results)) {
echo "<p>VIN_#: $row[vin]</p>";
echo "<p>Stock Number: $row[stockno]</p>";
echo "<p>Manufacturer Number: $row[man_num] </p>";
echo "<p>Model: $row[model] </p>";
echo "<p>Colour: Id $row[col_id] </p>";
echo "<p>Year: $row[year] </p>";
echo "<p>Price: $row[price] </p>";
echo "<p>Kilometres: $row[kms] </p>";
echo "<p>Registration: $row[rego] </p>";
echo "<p>Cylinders: $row[cylinders] </p>";
echo "<p>Fuel: $row[fuel] </p>";
echo "<p>Transmission: $row[transmission] </p>";
echo "<p>Category Id: $row[cat_id] </p>";
echo "<p>Vehicle On Special: $row[special] </p>";
echo "<p>Standard Used Vehicle: $row[standardusedvehicle] </p>";
}
}

?>

1 个答案:

答案 0 :(得分:0)

这不是一个真正的答案,但我不能在评论中发布此代码。尝试使用addind echos 来查看它的作用和不做的事情:

<?php
echo '1';
$conn = @mysqli_connect("localhost", "root", "2401", "taylor_callaghan_wca");

$query = "SELECT * FROM vehicle";
$results = mysqli_query($conn, $query);
if(!$results) {
    echo '2';
    echo ("Query error: " . mysqli_error($conn));
}

else {
    echo '3';
    // Fetch and display the results of the select query
    while ($row = mysqli_fetch_array($results)) {
        echo '4';
        echo "<p>VIN_#: $row[vin]</p>";
        echo "<p>Stock Number: $row[stockno]</p>";
        echo "<p>Manufacturer Number: $row[man_num] </p>";
        echo "<p>Model: $row[model] </p>";
        echo "<p>Colour: Id $row[col_id] </p>";
        echo "<p>Year: $row[year] </p>";
        echo "<p>Price: $row[price] </p>";
        echo "<p>Kilometres: $row[kms] </p>";
        echo "<p>Registration: $row[rego] </p>";
        echo "<p>Cylinders: $row[cylinders] </p>";
        echo "<p>Fuel: $row[fuel] </p>";
        echo "<p>Transmission: $row[transmission] </p>";
        echo "<p>Category Id: $row[cat_id] </p>";
        echo "<p>Vehicle On Special: $row[special] </p>";
        echo "<p>Standard Used Vehicle: $row[standardusedvehicle] </p>";
    }
}
echo '5';
?>