faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 16 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes


Why does mysql_fetch_array return a Resource instead of an Array?

Jan 24th, 2001 22:54
Joshua Ariizumi, mark romero, Onno Benschop, http://www.php.net/mysql_fetch_array

mysql_fetch_array() is the "deluxe" version of mysql_fetch_row().  
While mysql_fetch_row() returns a simple linear array of the results, 
mysql_fetch_array() returns an array that has both index and column 
name, so with
  $r = mysql_fetch_array($result);
you can refer to columns like
  echo $r["name"];
  echo $r[0];
which would be the same, assuming your first column in the result set 
was "name".
Manual Links: