Warning: mysqli_error() expects parameter 1 to be mysqli, null given in
<p>Warning: mysqli_error() expects parameter 1 to be mysqli, null given in error persists when am trying to upload a csv file into the database.</p>

<p>below is my code snippet. I don't where i could be misfiring.</p>

<pre><code>&lt;?php 

class UploadFIle
{
   function __construct()
{

}
public function insertFile($filename,$tableName){
    global $db_mysqli_connection;
    $queryTruncate="TRUNCATE table ".$tableName;
    mysqli_query($db_mysqli_connection,$queryTruncate);
    $handle = fopen($filename, "r");
    $query='INSERT INTO '.$tableName.' VALUES ';

     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $limit=sizeof($data);
        $query.='(';
        $counter=0;
        while($limit&gt;0){
            $query.="\"".$data[$counter]."\"".',';
            ++$counter;
            --$limit;
        }

        $query=rtrim($query,',');

        $query.='),';

     }
     $query=rtrim($query,',');
     mysqli_query($db_mysqli_connection,$query) or die(mysqli_error($connection).$query);

        if (mysqli_affected_rows($db_mysqli_connection)&lt;=0) {
           // echo "\nQuery execute failed: ERRNO: (" . $mysqli-&gt;errno . ") " . $mysqli-&gt;error;
            $csvMessage = "Upload Failed &lt;br/&gt;" . $db_mysqli_connection-&gt;error ;
        }else{
            $csvMessage = "Upload Successful";
        }
        return $csvMessage;
        //var_dump($mysqli);
}
</code></pre>

<p>}</p>

<p>?></p>