为什么我的PHP代码没有显示在我的Web浏览器中? 它只是一个空白的白页
问题描述:
So I am trying to connect to my database and display the Vehicles on the web page. However it is just coming up with a blank page, and not displaying anything.
Below is the code for the page I was to display the contents of vehicles on from my database
Any Ideas?
<?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>";
}
}
?>
答
It's not really an answer but I can't post this code in comment. Try addind echos to see what it does and what it doesn't:
<?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';
?>