Hello, I’m trying to query a database that is hosted by Bluehost. I can connect to the database successfully but when I run a query it returns nothing. As a complete novice I’m oblivious to why this is the case. There are over two hundred records in the table which I expected to be displayed but the web page is blank with no errors displayed or in the php log on the server. Here is my code:
<?php
$dbhost = 'localhost';
$dbuser = 'martstee_Guest';
$dbpass = '*************';
$dbname = 'martstee_WPSPT';
// Create connection
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$squery = "SELECT * FROM data products";
if ($result = mysqli_query($conn, $squery)) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['Code'] . "</td>";
echo "<td>" . $row['Qty'] . "</td>";
echo "<td>" . $row['Loc'] . "</td>";
echo "</tr>";
}
mysqli_free_result($result);
}
?>
Thank you in advance for taking the time to read this and hopefully advise. Any help is gratefully appreciated.
Cheers Martin