#41058 [Opn]: Difference in syntax for mysql_fetch_array
| From: | mattsoghoian at gmail dot com | Date: | Wed, 11 Apr 2007 22:05:09 +0000 |
| Subject: | #41058 [Opn]: Difference in syntax for mysql_fetch_array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111386@lists.php.net to get a copy of this message | ||
ID: 41058
User updated by: mattsoghoian at gmail dot com
Reported By: mattsoghoian at gmail dot com
Status: Open
Bug Type: Arrays related
Operating System: Windows 2003 / FreeBSD
PHP Version: 5.2.1
New Comment:
One other thing... The whole problem is that when unquoted, windows
sees the column name within the [] as a constant variable, where the
unix version does not.
Previous Comments:
------------------------------------------------------------------------
[2007-04-11 21:53:13] mattsoghoian at gmail dot com
Description:
------------
This is dealing with implementation of the return value of
mysql_fetch_array on the following two systems:
1:
FreeBSD 6.1-RELEASE
Apache 2.2.3
PHP 5.2.0
MySQL 5.0.27-standard
2:
Windows Server 2003 SP2 with IIS
PHP 5.2.1
MySQL 5.0.37-community
Basically, there seems to be two different ways of calling the array
returned by mysql_fetch_array which i listed below.
the first one is from my unix box, the second is from my windows box.
Notice that the second one has quotes around 'columnName', which makes
sense for an array, but i've never written code on windows until now,
and have always used the first piece of code when writing on *nix.
Reproduce code:
---------------
$line = mysql_fetch_array($result, MYSQL_ASSOC);
echo $line[columnName];
/**** OR ****/
$line = mysql_fetch_array($result, MYSQL_ASSOC);
echo $line['columnName'];
Expected result:
----------------
expected to echo the cell value of columnName that was pulled from the
query.
Actual result:
--------------
When you run the unquoted code on windows, you get this:
PHP Notice: Use of undefined constant id - assumed 'id' in
C:\Inetpub\wwwroot\orders\test.php on line 13
where as the quoted OR unquoted version works on unix.
here's the buggy part to me: if i do this...
echo "$line[columnName]";
where the whole echo is quoted, then it works fine on windows, where
sometimes it doesn't like that on unix (i think especially with
$_SESSION vars.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41058&edit=1