خرید بک لینک

Vote count: 0

This question has already been asked, and I've followed the answers but I'm still getting the error 'mysqli_fetch_assoc() expects parameter 1 to be mysqli_result'

My code

$host = "localhost";
$user = "my_user";
$user_pass = "my_password";
$dbase = "my_database";

$co = mysqli_coect($host, $user, $user_pass, $dbase );
if (!$co) {
    die("Coection failed: " . mysqli_coect_error());
}

$sql="select id, customer_name, date_ordered, amount from orders where status_id=5 and date_ordered >= '2016-01-01 00:00:00'";
$result = mysqli_query($co, $sql);

if($result === FALSE) { 
    die(mysqli_error($mysqli));
}

var_dump($result);

echo 'test =  '.mysqli_num_rows($result).'<br />';
if(mysqli_num_rows($result) > 0){
    while($row = mysqli_fetch_assoc($result)){
      //rest of code goes here
    }
}

The var_dump line retus:

object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(4) ["lengths"]=> NULL ["num_rows"]=> int(329) ["type"]=> int(0) } 

The while($row = mysqli_fetch_assoc($result)) line retus

Waing: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result

I really don't know what I'm doing wrong.

Thanks

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 22 خرداد 1395 ساعت: 16:27

صفحه بندی