I creating a php file that pulls a view from an SQL database. Can someone let me know why this isn't working? It seems to be timing out. I am not getting a connection error, either. Thank you in advance.
<?php
require ('mysqli_connect.php');
$sql = "SELECT * FROM testview ;";
$result = mysqli_query($dbc,$sql);
// Check connection if ($dbc->connect_error) {
die("Connection failed: " . $dbc->connect_error); }
$result=mysqli_query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>userID</th><th>first_name</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["userID"]."</td><td>".$row["first_name"]."</td></tr>";
}
echo "</table>"; } else {
echo "0 results"; }
}
$dbc->close();
?>
Here is the connection file
<?php
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'root');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'Test');
// Make the connection:
$dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' );
?>