note 19841 added to function.mysql-fetch-array

From: Date: Wed, 13 Mar 2002 00:48:24 +0000
Subject: note 19841 added to function.mysql-fetch-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-27694@lists.php.net to get a copy of this message
If you perform a SELECT query which returns different columns with duplicate names, like this: -------- $sql_statement = "SELECT tbl1.colA, tbl2.colA FROM tbl1 LEFT JOIN tbl2 ON tbl1.colC = tbl2.colC"; $result = mysql_query($sql_statement, $handle); $row = mysql_fetch_array($result); -------- Then $row[0] is equivalent to $row["colA"] but $row[1] is not equivalent to $row["colA"]. Moral of the story: You must use the numerical index on the result row arrays if column names are not unique, even if they come from different tables within a JOIN. This would render mysql_fetch_assoc() useless. -- http://www.php.net/manual/en/function.mysql-fetch-array.php http://master.php.net/manage/user-notes.php?action=edit+19841 http://master.php.net/manage/user-notes.php?action=delete+19841 http://master.php.net/manage/user-notes.php?action=reject+19841

« previous php.notes (#27694) next »