In this example why does the procedural way fail with this error:
Error:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given in /Users/joel/Sites/people_test/public_html/index.php on line 14
PHP:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
$q = "SELECT first_name, last_name FROM person LIMIT 0,30";
$r = mysqli_query($dbc, $q);
Procedural:
while($data = mysql_fetch_assoc($r)) {
$rows[] = $data;
}
//prints out null
echo json_encode($rows);
OOP:
while($data = $r->fetch_assoc()) {
$rows[] = $data;
}
echo json_encode($rows);
I thought I was doing the procedural way right from reading the PHP.net fetch_assoc() procedural and oop examples. Obviously I'm missing something. Could use some help seeing what it is.