php - Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, array given in -
this question has answer here:
i getting error "warning: mysqli_fetch_assoc() expects parameter 1 mysqli_result, array given in" out of code snippet "searchcar.php"
$modelmake = $_post['model_make']; $result = $db->select('car_information','*', 'model_make \'%$modelmake%\''); while($row = mysqli_fetch_assoc($result)) { echo 'model'.$row['model_make']; }
here code snippet "database.php" select function
public function select( $table, $fields = '*', $where = '1=1', $order = '', $limit = '', $desc = false, $limitbegin = 0, $groupby = null, $monitoring = false ) //monitoring set true view actual query { // $query ='select ' . $fields . ' ' . $table ; $query = 'select ' . $fields . ' ' . $table . ' ' . $where; if (!empty($groupby)) { $query .= ' group ' . $groupby; } if (!empty($order)) { $query .= ' order ' . $order; if ($desc) { $query .= ' desc'; } } if (!empty($limit)) { $query .= ' limit ' . $limitbegin . ', ' . $limit; } $result = $this->_sendquery($query); $resultarray = array(); while ($row = mysqli_fetch_assoc($result)) { $resultarray[] = $row; } if ($monitoring) { // if monitoring activated, echo query echo $query; } return $resultarray; }
i want use line "while($row = mysqli_fetch_assoc($result))" please advice!
your select
method returning array
, not resource
. means mysqli_fetch_assoc
right complain.
the news select
method returning array of results, means can replace while($row = mysqli_fetch_assoc($result))
with
foreach($result $row)
Comments
Post a Comment