Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works
| From: | jpaulomf at terra dot com dot br | Date: | Fri, 22 Feb 2002 15:02:11 +0000 |
| Subject: | Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-824@lists.php.net to get a copy of this message | ||
ID: 15673
Updated by: jpaulomf@terra.com.br
-Summary: Quotes crash MySQL queries: $array['val'] = Parse
Error, but $array[val] works
Reported By: jpaulomf@terra.com.br
Status: Closed
Bug Type: Arrays related
Operating System: Linux 2.4.5
PHP Version: 4.1.1
New Comment:
Ok, but I think it should be seen as a BUG, since we cannot call the
array as it should be and we are able to call it as it shouldn't.
PHP is expected work with codes like:
sql_query("SELECT * from $array['table']");
and its expected to (but doesnt have to) work with:
sql_query("SELECT * from $array[table]");
and in such case its expected to give a warning...
in both cases the behavior of 4.1.1 is buggy...
Thanks for your time people!
Best Regards
João Paulo M. Fischer
Previous Comments:
------------------------------------------------------------------------
[2002-02-22 09:42:58] hholzgra@php.net
i'll close this here and create a feature request
for "$array['index']" to be possible or for a better
error message at least ...
see http://bugs.php.net/15677
------------------------------------------------------------------------
[2002-02-22 08:40:58] jpaulomf@terra.com.br
And the Parse Error, do you get it with the cvs ver too?
------------------------------------------------------------------------
[2002-02-22 08:29:58] mfischer@php.net
Ah, I see. No, there's no warning either.
------------------------------------------------------------------------
[2002-02-22 08:25:33] jpaulomf@terra.com.br
Yes, I know your code works, thats not the problem.
Now change your own code:
echo $foo[key]; ==to==> echo "Key value is $foo[key]"; // No
warnings!!!!!
And then TRY:
echo "$foo['key']"; // PARSE ERROR!!!
Does it happens with the cvs version?
------------------------------------------------------------------------
[2002-02-22 08:12:54] mfischer@php.net
Work's right with CVS:
$ php
<?
error_reporting(E_ALL);
$foo['key'] = 'value';
echo $foo[key];
?>
X-Powered-By: PHP/4.2.0-dev
Content-type: text/html
<br />
<b>Warning</b>: Use of undefined constant key - assumed 'key' in
<b>-</b> on line <b>4</b><br />
-(4) : Warning - Use of undefined constant key - assumed 'key'
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/15673
--
Edit this bug report at http://bugs.php.net/?id=15673&edit=1