So I am a beginner in PHP and am using MySQL to make a simple CRUD application. I am done with making the CRUD application table and also have successfully connected it with my MySQL database. However, when I load the page on the server, I am facing errors which I am unable to debug. Here is part of code for my CRUD table in which I am facing the error (lines 57-74 of my code):
// Attempt select query execution my
$sql = "SELECT * FROM students";
if($result = $mysqli->query($sql)){
if($result->num_rows > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>id</th>";
echo "<th>Name</th>";
echo "<th>Father's Name</th>";
echo "<th>Mother's Name</th>";
echo "<th>Email</th>";
echo "<th>Contact</th>";
echo "<th>Alt. Contact</th>";
echo "<th>Alt. Contact</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
Here is the error I am getting:
Notice: Undefined variable: mysqli in /Applications/XAMPP/xamppfiles/htdocs/student/options2.php on line 59
Fatal error: Uncaught Error: Call to a member function query() on null in /Applications/XAMPP/xamppfiles/htdocs/student/options2.php:59 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/student/options2.php on line 59