I am unable to understand why this error is popping up. I do know that the obvious reason why these kind of errors come up but I did look and re-look into my code and cannot understand why!
The error is:
Fatal error: Call to a member function prepare() on a non-object
Here are the code snippets.
db_connect.php
<?php
include_once 'psl-config.php';   // As functions.php is not included
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
customer.php
include_once 'includes/db_connect.php';
include_once 'includes/functions.php';
.
.
.
function myCallBackFunction($array) {
                //echo ".";
               // print_r($array);
                $amount=$array['amount'];
                $date=$array['date'];                    
                if(transaction($mysqli, $date, $amount))
                {
                    echo "Transaction table Updated";
                }
            }
functions.php
//Function to insert transactions
function transaction($mysqli, $date, $amount) {
    if($smt = $mysqli->prepare("INSERT INTO `tbltransaction` (entry_date,income) VALUES (?,?)
  ON DUPLICATE KEY UPDATE income=income+?;"));
    {
        $stmt->bind_param('sii', $date, $amount, $amount);  // Bind "$date" and "$amount" to parameter.               
        $stmt->execute();    // Execute the prepared query.
        $stmt->store_result();
        if ($stmt->num_rows == 1) {
            return true;
        } else {
            return false;
        }
    }
}
tbltransaction
Column  Type    Null    Default     Comments    MIME
entry_date  date    No           
income  int(11) No 
P.S: another function in the functions.php file is working just fine, here is the function and the way I am calling it
function
//Function to display notice
function notice($mysqli) {
    $notice = null;
    if ($stmt = $mysqli->prepare("SELECT notice FROM tblnotice ORDER BY ID DESC LIMIT 1")) {
        $stmt->execute();    // Execute the prepared query.
        $stmt->store_result();
        // get variables from result.
        $stmt->bind_result($notice);
        $stmt->fetch();
        return $notice;
    }
}
calling the function
<?php echo notice($mysqli); ?>
 
     
     
    