Udemy REST Assured free

PHP Database Interview Questions

Showing 1 - 1 of 1 results

What is the difference between PHP mysql_fetch_array() and msql_fetch_object() functions?

Both mysql_fetch_array() and mysql_fetch_object() are built-in methods of PHP to retrieve records from MySQL database table.

The difference between these methods is that mysql_fetch_array() returns the result set as an array and mysql_fetch_object() returns the result set as an object.

$result = mysql_query("SELECT id, name FROM clients");

while ($row = mysql_fetch_array($result, MYSQL_NUM)) 
    printf("ID: %s  Name: %s", $row[0], $row[1]);

while ($row = mysql_fetch_object($result))
    printf("ID: %s  Name: %s", $row->id, $row->name);
Subscribe to PHP Database Interview Questions