3

I have a webpage that was working yesterday. It is a very basic page that has a very simple php table in it. However i attempted to add another column today and now the page won't load it doesn't even show the code when i inspect the element of the webpage. It will display when I rename the index.php to index.html but then of course the php table doesn't work. Any help would be appreciated. Also I tried a different 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();
?>
Alex Andrei
  • 7,315
  • 3
  • 28
  • 42

1 Answers1

4

You aren't concatenating a string in the loop:

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

Should be

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

For tracking down these errors in the future see: How do I get PHP errors to display?

Community
  • 1
  • 1
Jim
  • 22,354
  • 6
  • 52
  • 80