I'm trying to create a database with MySQL and PHP, however using echo
does not work after calling require_once
.
<?php
echo "before";
require_once("../mysql_connect.php");
echo "after";
$query = "SELECT first_name, last_name, email, password FROM account";
$response = @mysqli_query($dbc, $query);
if($response){
echo '<table align="left"
cellspacing="5" cellpadding="8">
<tr><td align="left"><b>First Name</b></td>
<td align="left"><b>Last Name</b></td>
<td align="left"><b>Email</b></td>
<td align="left"><b>Password</b></td>';
while($row = mysqli_fetch_array($response)){
echo '<tr><td align="left">' .
$row['first_name'] . '</td><td align="left">' .
$row['last_name'] . '</td><td align="left">' .
$row['email'] . '</td><td align="left">' .
$row['password'] . '</td><td align="left">';
echo '</tr>';
}
echo '</table>';
} else {
echo "Couldn't issue database query<br />";
echo mysqli_error($dbc);
}
mysqli_close($dbc);
?>
If run through the terminal, this works exactly as expected. When run through a web browser, it only prints out 'before' and nothing else. Does anyone know how to fix this? Thanks in advance.