I’ve had this problem before also and I posted the question but my account was on hold and that question got lost in millions of other questions before it could be answered so I am asking it again.
I am connecting a very simple page to mysqli database to fetch data from mysqli but the page is showing blank. Here is the code that I am using.
<?php
// 1. Create a database connection
$dbhost = "localhost";
$dbuser = "widget_cms";
$dbpass = "Jaseemkhan@81";
$dbname = "widget_corp";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
// Test if connection succeeded
if (mysqli_connect_errno()){
die("Database Connection failed: " .
mysqli_connect_error () .
" (" . mysqli_connect_errno() . " )"
);
}
?>
<?php include("../includes/functions.php");?>
<?php
// 2. Perform database query
$query = "select * from subjects
where visible = 1
order by position ASC";
$result = mysqli_query($connection, $query);
// Test if there was a query error
if (!$result){
die("Database query failed.");
}
?>
<?php include("../includes/layouts/header.php");?>
<div id = "main">
<div id="navigation">
<ul>
<?php
// 3. Use returned data (if any)
while ($subject = mysqli_fetch_assoc($result)){
// output data from each row
?>
<li><?php echo $subject ["menu_name"] . " (" .
$subject["id"] . ")";?></li>
}
</ul>
</div>
<div id="page">
<h2>Manage Content</h2>
</div>
</div>
<?php
// 4. Release returned data
mysqli_free_result($result);
?>
<?php include("../includes/layouts/footer.php");?>
<?php
// 5. Close the database connection
mysqli_close($connection);
?>