The web page does not render php

I have a webpage that was working yesterday. This is a very simple page with a very simple php table. However, I tried to add another column today and now the page won't load, won't even show the code when checking the web page element. It will show up when I rename index.php to index.html, but then of course the php table doesn't work. Any help would be greatly appreciated. Also I tried another index.php page and it worked

Here is my php:

<?php
$servername = "ip";
$username = "username";
$password = "password";
$dbname = "Prices";

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

$sql = "SELECT * FROM `prices` ORDER BY `prices`.`Name` ASC";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
echo "<table><tr><th>Name</th><th>Price In $||</th><th>Price in Ref</th><th>Quantity</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
  echo "<tr><td>" . $row["Name"]. "</td><td>" . $row["Price"]. "</td><td>" . $row["Price_in_Metal"]. "</td><td>" . $row ["Quantity"]"</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>

      

+3


source to share


1 answer


You are not concatenating the string in a loop:

$row ["Quantity"]"</td></tr>";

      

Should be



$row ["Quantity"] . "</td></tr>";

      

For future track of these errors see: How do I get PHP errors?

+4


source







All Articles