I have the code that has been giving me the following error.
Trying to get property of non-object in G:\xampp\htdocs\abc\admin\delete.php on line 68
Here's the code,
<?php
    if(isset($_POST["submit"])) {
    include '../includes/db.php';
    $sql = "DELETE FROM admin WHERE aid= '".$_POST['aid']. "'";
    $result = $conn->query($sql);
    $count = $result->num_rows;
    if ($count > 0) {
        echo "success";
    } else {
        echo "fail";
    }
    $conn->close();
    }
?>
db.php has the code that connects to the database.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "fgfg";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
?>
It executes the query but the error message is displayed.
What is causing it?
 
     
    