#41058 [Opn->Bgs]: Difference in syntax for mysql_fetch_array
| From: | tony2001@php.net | Date: | Wed, 11 Apr 2007 22:07:48 +0000 |
| Subject: | #41058 [Opn->Bgs]: Difference in syntax for mysql_fetch_array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111387@lists.php.net to get a copy of this message | ||
ID: 41058
Updated by: tony2001@php.net
Reported By: mattsoghoian at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Windows 2003 / FreeBSD
PHP Version: 5.2.1
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2007-04-11 22:05:09] mattsoghoian at gmail dot com
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.
------------------------------------------------------------------------
[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