Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqli - fetch_Array error call to a member function fetch_array() on a non-object mysqli [duplicate]

I am new to mysqli and started trying to learn basic things. With respect to this i example (http://php.net/manual/en/mysqli-result.fetch-array.php) i was trying fetch_array. Here is my code.

$sqlGetChartData    =   "SELECT date, ratepersqft, location 
                          FROM ratepersqft
                         WHERE project_id = 1";
$runGetChartData    =   $mysqli->query($sqlGetChartData);

while($rowGetChartData = $runGetChartData->fetch_array(MYSQLI_BOTH))
    $arrGetChartData[]  =   $rowGetChartData;

    print "<pre>";
    print_r($arrGetChartData);
    exit();

Here i am getting this error Call to a member function fetch_array() on a non-object on line next to while condition line. I tried googling it and did not get result for my problem. Hope my question is clear. Thanks in Advance.

like image 489
Vignesh Gopalakrishnan Avatar asked Feb 01 '13 04:02

Vignesh Gopalakrishnan


1 Answers

This answer has been written very long time ago and become irrelevant.

Since then I learned the proper solution for this problem and wrote it in this answer. Please navigate there.

like image 196
Your Common Sense Avatar answered Oct 21 '22 03:10

Your Common Sense