note 13732 deleted from ref.mysql by betz

From: Date: Wed, 21 Apr 2004 10:09:34 +0000
Subject: note 13732 deleted from ref.mysql by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-68421@lists.php.net to get a copy of this message
Note Submitter: davey@shakedownwizards.com ---- The mysql_fetch_row function returns an array with numeric indices. For example, a row from the query: SELECT bookid,title,author FROM books would look like: $record[0]=3 $record[1]="A Farewell To Arms" $record[2]="Ernest Hemingway" The mysql_fetch_assoc function returns an array with indices that are the field names, like such: $record["bookid"]=3 $record["title"]="A Farewell To Arms" $record["author"]="Ernest Hemingway" The mysql_fetch_array function returns an array with both kinds of indices, so this array looks like: $record[0]=3 $record["bookid"]=3 $record[1]="A Farewell To Arms" $record["title"]="A Farewell To Arms" $record[2]="Ernest Hemingway" $record["author"]="Ernest Hemingway" This is the reason for the "doubled" field output from the example. Note that the mysql_fetch_array function has an optional parameter where you can specify the indices. So replacing the call: mysql_fetch_array($result) with: mysql_fetch_array($result,MYSQL_NUM) would be an identical fix to: mysql_fetch_row($result) Hope this helps!

« previous php.notes (#68421) next »