php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41058 Difference in syntax for mysql_fetch_array
Submitted: 2007-04-11 21:53 UTC Modified: 2007-04-11 22:07 UTC
From: mattsoghoian at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.1 OS: Windows 2003 / FreeBSD
Private report: No CVE-ID: None
 [2007-04-11 21:53 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-11 22:05 UTC] 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 22:07 UTC] tony2001@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 10:01:32 2024 UTC