I am trying to show values from DB onto a web page. Here is the code below.
//connect db
$dbc = mysqli_connect('localhost', 'root', '', 'mylearndb') OR die('Cannot connect because: '.mysqli_connect_error());
//Run query...
$q = "SELECT * FROM 'pages' WHERE id = 1";
$r = mysqli_query($dbc, $q);
$page = mysqli_fetch_assoc($r);
In the index page, I am trying to print the results in a table:
<table>
<tr>
<td>Customer ID</td>
<td>Full Name</td>
<td>Email ID</td>
<td>Phone no</td>
</tr>
<tr>
<td><?php echo $page['cust_id']; ?></td>
<td><?php echo $page['full_name']; ?></td>
<td><?php echo $page['email_id']; ?></td>
<td><?php echo $page['phone_no']; ?></td>
</tr>
</table>
When I go and check the page, it throws the error...
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in..
The above code runs in a file called setup.php
and I call that file into index.php
.