Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpage not displaying php [closed]

Tags:

php

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();
?>
like image 289
Daniel Prinsloo Avatar asked Dec 31 '25 10:12

Daniel Prinsloo


1 Answers

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?

like image 86
Jim Avatar answered Jan 01 '26 23:01

Jim