I'm new at PHP, and trying to set up a simple test to get data to return from a temp database I set up, but I keep getting a syntax error. I've looked it over and after the process of elimination, it seems to be in this line, but I'm not sure what's wrong since I'm pretty sure it looks just like the tutorial I'm using.
while($row = mysqli_fetch_row($result)) {
Here is the all the code relevant to what I'm doing:
<?php
// Perform database query
$query = "SELECT * FROM subjects";
$result = mysqli_query($connection, $query);
// Test if there was a query error
if (!$result) {
die ("Database query failed.");
}
?>
<?php
// Use returned data (if any)
while($row = mysqli_fetch_row($result)) {
// output data from each row
var_dump($row);
echo "<hr />";
?>
I'm able to successfully make the initial connection, etc, it's just when I tried to get data to show up from the database that I got the syntax error.