Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread philip

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Closed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Constants are not looked for within strings, this is why "$foo[key]"
does not generate a warning here.  But outside of strings this is a
different story.

define ('a','b');
$arr = array('a' => 'apple', 'b' => 'banana');
print $arr['a'];// apple
print $arr[a];  // banana
print "$arr[a]" // apple
print "$arr['a']"   // parse error
print "{$arr['a']}" // apple

This bug report is a feature request for "$arr['a']" to print apple. 
Regarding print $arr[a] above, if 'a' was not a defined constant, a
warning would exist but apple is still printed (if key 'a' exists).


Previous Comments:


[2002-02-22 11:44:45] [EMAIL PROTECTED]

> no warning is generated here as no define() substitution
> is done in strings
Why no define() is applied to the string??

>From the PHP manual:
[quote]Why is $foo[bar] wrong?[/quote]
[quote]...there must be an expression between the square brackets ('['
and ']').[/quote]

Since there is no expression, the workaround IS to make a define() to
the string or integer between the []s and set the value to its own
name. 

error_reporting(E_ALL);
define("ke","key");

$foo['key'] = 'aaa';
$foo['ke'] = 'bbb';
echo "It is"
."Foo[ke] ==> $foo[ke]";
echo "It should be:"
."Foo[ke] ==> ".$foo[ke];

Ok, we can deal with this, but thats not the way it should work
according with the good sense and the manual..

Regards



[2002-02-22 10:31:22] [EMAIL PROTECTED]

> PHP is expected work with codes like:
> sql_query("SELECT * from $array['table']"); 

one *could* expect that it understood this,
that's what my feature request is about,
but "PHP is expected" is not right


> 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...

no, this is the current and expected behavior
no warning is generated here as no define() substitution
is done in strings

> in both cases the behavior of 4.1.1 is buggy...
it has been like this ever since 3.0, so you can't
call this 'buggy', call it 'unexpected  behaviour',
'inconsistent design' or whatever, but it is not
a bug ...






[2002-02-22 10:02:10] [EMAIL PROTECTED]

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



[2002-02-22 09:42:58] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

And the Parse Error, do you get it with the cvs ver too?



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Closed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

> no warning is generated here as no define() substitution
> is done in strings
Why no define() is applied to the string??

>From the PHP manual:
[quote]Why is $foo[bar] wrong?[/quote]
[quote]...there must be an expression between the square brackets ('['
and ']').[/quote]

Since there is no expression, the workaround IS to make a define() to
the string or integer between the []s and set the value to its own
name. 

error_reporting(E_ALL);
define("ke","key");

$foo['key'] = 'aaa';
$foo['ke'] = 'bbb';
echo "It is"
."Foo[ke] ==> $foo[ke]";
echo "It should be:"
."Foo[ke] ==> ".$foo[ke];

Ok, we can deal with this, but thats not the way it should work
according with the good sense and the manual..

Regards


Previous Comments:


[2002-02-22 10:31:22] [EMAIL PROTECTED]

> PHP is expected work with codes like:
> sql_query("SELECT * from $array['table']"); 

one *could* expect that it understood this,
that's what my feature request is about,
but "PHP is expected" is not right


> 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...

no, this is the current and expected behavior
no warning is generated here as no define() substitution
is done in strings

> in both cases the behavior of 4.1.1 is buggy...
it has been like this ever since 3.0, so you can't
call this 'buggy', call it 'unexpected  behaviour',
'inconsistent design' or whatever, but it is not
a bug ...






[2002-02-22 10:02:10] [EMAIL PROTECTED]

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



[2002-02-22 09:42:58] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

And the Parse Error, do you get it with the cvs ver too?



[2002-02-22 08:29:58] [EMAIL PROTECTED]

Ah, I see. No, there's no warning either.



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread hholzgra

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Closed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

> PHP is expected work with codes like:
> sql_query("SELECT * from $array['table']"); 

one *could* expect that it understood this,
that's what my feature request is about,
but "PHP is expected" is not right


> 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...

no, this is the current and expected behavior
no warning is generated here as no define() substitution
is done in strings

> in both cases the behavior of 4.1.1 is buggy...
it has been like this ever since 3.0, so you can't
call this 'buggy', call it 'unexpected  behaviour',
'inconsistent design' or whatever, but it is not
a bug ...





Previous Comments:


[2002-02-22 10:02:10] [EMAIL PROTECTED]

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



[2002-02-22 09:42:58] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

And the Parse Error, do you get it with the cvs ver too?



[2002-02-22 08:29:58] [EMAIL PROTECTED]

Ah, I see. No, there's no warning either.



[2002-02-22 08:25:33] [EMAIL PROTECTED]

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?



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 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] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

And the Parse Error, do you get it with the cvs ver too?



[2002-02-22 08:29:58] [EMAIL PROTECTED]

Ah, I see. No, there's no warning either.



[2002-02-22 08:25:33] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

Work's right with CVS:

$ php 

X-Powered-By: PHP/4.2.0-dev
Content-type: text/html


Warning:  Use of undefined constant key - assumed 'key' in
- on line 4
-(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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread hholzgra

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
-Status:   Analyzed
+Status:   Closed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

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



Previous Comments:


[2002-02-22 08:40:58] [EMAIL PROTECTED]

And the Parse Error, do you get it with the cvs ver too?



[2002-02-22 08:29:58] [EMAIL PROTECTED]

Ah, I see. No, there's no warning either.



[2002-02-22 08:25:33] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

Work's right with CVS:

$ php 

X-Powered-By: PHP/4.2.0-dev
Content-type: text/html


Warning:  Use of undefined constant key - assumed 'key' in
- on line 4
-(4) : Warning - Use of undefined constant key - assumed 'key'



[2002-02-22 07:52:32] [EMAIL PROTECTED]

I did this tests using error_reporting(E_ALL);

Thats my point, the correct array syntax according the doc:
http://www.php.net/manual/en/language.types.array.php
is to call $array['value'] even thought $array[value] will work, but in
the later case it should send a NOTICE warning.

well, try this in you system:

error_reporting(E_ALL);
$arr = array( 'foo'  =>  'bar', 'etc' => 'other');

//This will make a Parse Error in PHP 4.1.1:
//echo "Foo value is $arr['foo']";
//This works:
echo "Foo value is ".$arr['foo'];
echo "Foo value is {$arr['foo']}";

//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// This will get a parse error
echo "Foo value is $arr['foo']";



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

And the Parse Error, do you get it with the cvs ver too?


Previous Comments:


[2002-02-22 08:29:58] [EMAIL PROTECTED]

Ah, I see. No, there's no warning either.



[2002-02-22 08:25:33] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

Work's right with CVS:

$ php 

X-Powered-By: PHP/4.2.0-dev
Content-type: text/html


Warning:  Use of undefined constant key - assumed 'key' in
- on line 4
-(4) : Warning - Use of undefined constant key - assumed 'key'



[2002-02-22 07:52:32] [EMAIL PROTECTED]

I did this tests using error_reporting(E_ALL);

Thats my point, the correct array syntax according the doc:
http://www.php.net/manual/en/language.types.array.php
is to call $array['value'] even thought $array[value] will work, but in
the later case it should send a NOTICE warning.

well, try this in you system:

error_reporting(E_ALL);
$arr = array( 'foo'  =>  'bar', 'etc' => 'other');

//This will make a Parse Error in PHP 4.1.1:
//echo "Foo value is $arr['foo']";
//This works:
echo "Foo value is ".$arr['foo'];
echo "Foo value is {$arr['foo']}";

//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// This will get a parse error
echo "Foo value is $arr['foo']";



[2002-02-22 07:40:57] [EMAIL PROTECTED]

Yes, I get you get a NOTICE warning when you use $array[key] (because
key will be an undefined constant and therefore evaluate to a string).

Try with error_reporting(E_ALL); before using this syntax.



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread mfischer

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Ah, I see. No, there's no warning either.


Previous Comments:


[2002-02-22 08:25:33] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

Work's right with CVS:

$ php 

X-Powered-By: PHP/4.2.0-dev
Content-type: text/html


Warning:  Use of undefined constant key - assumed 'key' in
- on line 4
-(4) : Warning - Use of undefined constant key - assumed 'key'



[2002-02-22 07:52:32] [EMAIL PROTECTED]

I did this tests using error_reporting(E_ALL);

Thats my point, the correct array syntax according the doc:
http://www.php.net/manual/en/language.types.array.php
is to call $array['value'] even thought $array[value] will work, but in
the later case it should send a NOTICE warning.

well, try this in you system:

error_reporting(E_ALL);
$arr = array( 'foo'  =>  'bar', 'etc' => 'other');

//This will make a Parse Error in PHP 4.1.1:
//echo "Foo value is $arr['foo']";
//This works:
echo "Foo value is ".$arr['foo'];
echo "Foo value is {$arr['foo']}";

//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// This will get a parse error
echo "Foo value is $arr['foo']";



[2002-02-22 07:40:57] [EMAIL PROTECTED]

Yes, I get you get a NOTICE warning when you use $array[key] (because
key will be an undefined constant and therefore evaluate to a string).

Try with error_reporting(E_ALL); before using this syntax.



[2002-02-22 07:25:35] [EMAIL PROTECTED]

Hey man WOW, Im impressed, you have already replied!!!

Yes, this solution works:

$query = "SELECT * from {$table['users']}";

But shouldn't "Blah $table['users']" work as well?

Shouldn't PHP at least send a warning when using "$table[users]" even
if the other "$arr['foo']" syntaxes where wrong?

Thanks!



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

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?


Previous Comments:


[2002-02-22 08:12:54] [EMAIL PROTECTED]

Work's right with CVS:

$ php 

X-Powered-By: PHP/4.2.0-dev
Content-type: text/html


Warning:  Use of undefined constant key - assumed 'key' in
- on line 4
-(4) : Warning - Use of undefined constant key - assumed 'key'



[2002-02-22 07:52:32] [EMAIL PROTECTED]

I did this tests using error_reporting(E_ALL);

Thats my point, the correct array syntax according the doc:
http://www.php.net/manual/en/language.types.array.php
is to call $array['value'] even thought $array[value] will work, but in
the later case it should send a NOTICE warning.

well, try this in you system:

error_reporting(E_ALL);
$arr = array( 'foo'  =>  'bar', 'etc' => 'other');

//This will make a Parse Error in PHP 4.1.1:
//echo "Foo value is $arr['foo']";
//This works:
echo "Foo value is ".$arr['foo'];
echo "Foo value is {$arr['foo']}";

//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// This will get a parse error
echo "Foo value is $arr['foo']";



[2002-02-22 07:40:57] [EMAIL PROTECTED]

Yes, I get you get a NOTICE warning when you use $array[key] (because
key will be an undefined constant and therefore evaluate to a string).

Try with error_reporting(E_ALL); before using this syntax.



[2002-02-22 07:25:35] [EMAIL PROTECTED]

Hey man WOW, Im impressed, you have already replied!!!

Yes, this solution works:

$query = "SELECT * from {$table['users']}";

But shouldn't "Blah $table['users']" work as well?

Shouldn't PHP at least send a warning when using "$table[users]" even
if the other "$arr['foo']" syntaxes where wrong?

Thanks!



[2002-02-22 07:17:21] [EMAIL PROTECTED]

Use the {$array['key']} syntax as I told you.

However, I can't remember if "foo $array['bar']" ever worked or not
right now. Someone else?



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread mfischer

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Work's right with CVS:

$ php 

X-Powered-By: PHP/4.2.0-dev
Content-type: text/html


Warning:  Use of undefined constant key - assumed 'key' in
- on line 4
-(4) : Warning - Use of undefined constant key - assumed 'key'


Previous Comments:


[2002-02-22 07:52:32] [EMAIL PROTECTED]

I did this tests using error_reporting(E_ALL);

Thats my point, the correct array syntax according the doc:
http://www.php.net/manual/en/language.types.array.php
is to call $array['value'] even thought $array[value] will work, but in
the later case it should send a NOTICE warning.

well, try this in you system:

error_reporting(E_ALL);
$arr = array( 'foo'  =>  'bar', 'etc' => 'other');

//This will make a Parse Error in PHP 4.1.1:
//echo "Foo value is $arr['foo']";
//This works:
echo "Foo value is ".$arr['foo'];
echo "Foo value is {$arr['foo']}";

//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// This will get a parse error
echo "Foo value is $arr['foo']";



[2002-02-22 07:40:57] [EMAIL PROTECTED]

Yes, I get you get a NOTICE warning when you use $array[key] (because
key will be an undefined constant and therefore evaluate to a string).

Try with error_reporting(E_ALL); before using this syntax.



[2002-02-22 07:25:35] [EMAIL PROTECTED]

Hey man WOW, Im impressed, you have already replied!!!

Yes, this solution works:

$query = "SELECT * from {$table['users']}";

But shouldn't "Blah $table['users']" work as well?

Shouldn't PHP at least send a warning when using "$table[users]" even
if the other "$arr['foo']" syntaxes where wrong?

Thanks!



[2002-02-22 07:17:21] [EMAIL PROTECTED]

Use the {$array['key']} syntax as I told you.

However, I can't remember if "foo $array['bar']" ever worked or not
right now. Someone else?



[2002-02-22 07:12:54] [EMAIL PROTECTED]

It seems we cannot use the correct syntax $table['users'] inside the
two ""...

This will work:
$result = mysql_query("SELECT * from ".$table['users']);

This wont work:
$result = mysql_query("SELECT * from $table['users']");

This will, but should send a warning and it isnt:
$result = mysql_query("SELECT * from $table[users]");

The errors happens everywere I call any array with the '' or "" like
$table["something"] or $table['something'] inside ""s...



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

I did this tests using error_reporting(E_ALL);

Thats my point, the correct array syntax according the doc:
http://www.php.net/manual/en/language.types.array.php
is to call $array['value'] even thought $array[value] will work, but in
the later case it should send a NOTICE warning.

well, try this in you system:

error_reporting(E_ALL);
$arr = array( 'foo'  =>  'bar', 'etc' => 'other');

//This will make a Parse Error in PHP 4.1.1:
//echo "Foo value is $arr['foo']";
//This works:
echo "Foo value is ".$arr['foo'];
echo "Foo value is {$arr['foo']}";

//This will work but WON'T send a warning as the doc says:
echo "Foo value is $arr[foo]";
// This will get a parse error
echo "Foo value is $arr['foo']";


Previous Comments:


[2002-02-22 07:40:57] [EMAIL PROTECTED]

Yes, I get you get a NOTICE warning when you use $array[key] (because
key will be an undefined constant and therefore evaluate to a string).

Try with error_reporting(E_ALL); before using this syntax.



[2002-02-22 07:25:35] [EMAIL PROTECTED]

Hey man WOW, Im impressed, you have already replied!!!

Yes, this solution works:

$query = "SELECT * from {$table['users']}";

But shouldn't "Blah $table['users']" work as well?

Shouldn't PHP at least send a warning when using "$table[users]" even
if the other "$arr['foo']" syntaxes where wrong?

Thanks!



[2002-02-22 07:17:21] [EMAIL PROTECTED]

Use the {$array['key']} syntax as I told you.

However, I can't remember if "foo $array['bar']" ever worked or not
right now. Someone else?



[2002-02-22 07:12:54] [EMAIL PROTECTED]

It seems we cannot use the correct syntax $table['users'] inside the
two ""...

This will work:
$result = mysql_query("SELECT * from ".$table['users']);

This wont work:
$result = mysql_query("SELECT * from $table['users']");

This will, but should send a warning and it isnt:
$result = mysql_query("SELECT * from $table[users]");

The errors happens everywere I call any array with the '' or "" like
$table["something"] or $table['something'] inside ""s...



[2002-02-22 07:06:12] [EMAIL PROTECTED]

Sorry: The error occurs when we define the $query:

$query = "SELECT * from $table[users]"; // => This causes the parse
error

echo "Table $table['users']" //=> Parse Error too
echo "Table".$table['users']; //=>OK
$query = "SELECT * from ".$table['users']; //=> OK TOO



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread mfischer

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Yes, I get you get a NOTICE warning when you use $array[key] (because
key will be an undefined constant and therefore evaluate to a string).

Try with error_reporting(E_ALL); before using this syntax.


Previous Comments:


[2002-02-22 07:25:35] [EMAIL PROTECTED]

Hey man WOW, Im impressed, you have already replied!!!

Yes, this solution works:

$query = "SELECT * from {$table['users']}";

But shouldn't "Blah $table['users']" work as well?

Shouldn't PHP at least send a warning when using "$table[users]" even
if the other "$arr['foo']" syntaxes where wrong?

Thanks!



[2002-02-22 07:17:21] [EMAIL PROTECTED]

Use the {$array['key']} syntax as I told you.

However, I can't remember if "foo $array['bar']" ever worked or not
right now. Someone else?



[2002-02-22 07:12:54] [EMAIL PROTECTED]

It seems we cannot use the correct syntax $table['users'] inside the
two ""...

This will work:
$result = mysql_query("SELECT * from ".$table['users']);

This wont work:
$result = mysql_query("SELECT * from $table['users']");

This will, but should send a warning and it isnt:
$result = mysql_query("SELECT * from $table[users]");

The errors happens everywere I call any array with the '' or "" like
$table["something"] or $table['something'] inside ""s...



[2002-02-22 07:06:12] [EMAIL PROTECTED]

Sorry: The error occurs when we define the $query:

$query = "SELECT * from $table[users]"; // => This causes the parse
error

echo "Table $table['users']" //=> Parse Error too
echo "Table".$table['users']; //=>OK
$query = "SELECT * from ".$table['users']; //=> OK TOO



[2002-02-22 06:59:46] [EMAIL PROTECTED]

d



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Hey man WOW, Im impressed, you have already replied!!!

Yes, this solution works:

$query = "SELECT * from {$table['users']}";

But shouldn't "Blah $table['users']" work as well?

Shouldn't PHP at least send a warning when using "$table[users]" even
if the other "$arr['foo']" syntaxes where wrong?

Thanks!


Previous Comments:


[2002-02-22 07:17:21] [EMAIL PROTECTED]

Use the {$array['key']} syntax as I told you.

However, I can't remember if "foo $array['bar']" ever worked or not
right now. Someone else?



[2002-02-22 07:12:54] [EMAIL PROTECTED]

It seems we cannot use the correct syntax $table['users'] inside the
two ""...

This will work:
$result = mysql_query("SELECT * from ".$table['users']);

This wont work:
$result = mysql_query("SELECT * from $table['users']");

This will, but should send a warning and it isnt:
$result = mysql_query("SELECT * from $table[users]");

The errors happens everywere I call any array with the '' or "" like
$table["something"] or $table['something'] inside ""s...



[2002-02-22 07:06:12] [EMAIL PROTECTED]

Sorry: The error occurs when we define the $query:

$query = "SELECT * from $table[users]"; // => This causes the parse
error

echo "Table $table['users']" //=> Parse Error too
echo "Table".$table['users']; //=>OK
$query = "SELECT * from ".$table['users']; //=> OK TOO



[2002-02-22 06:59:46] [EMAIL PROTECTED]

d



[2002-02-22 06:55:12] [EMAIL PROTECTED]

Sounds very strange. Can you do a var_dump() on the sql string?

Can you also test and report back if it works with

  "SELECT * from {$table['users']}"

?



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




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread mfischer

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
-Status:   Open
+Status:   Analyzed
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Use the {$array['key']} syntax as I told you.

However, I can't remember if "foo $array['bar']" ever worked or not
right now. Someone else?


Previous Comments:


[2002-02-22 07:12:54] [EMAIL PROTECTED]

It seems we cannot use the correct syntax $table['users'] inside the
two ""...

This will work:
$result = mysql_query("SELECT * from ".$table['users']);

This wont work:
$result = mysql_query("SELECT * from $table['users']");

This will, but should send a warning and it isnt:
$result = mysql_query("SELECT * from $table[users]");

The errors happens everywere I call any array with the '' or "" like
$table["something"] or $table['something'] inside ""s...



[2002-02-22 07:06:12] [EMAIL PROTECTED]

Sorry: The error occurs when we define the $query:

$query = "SELECT * from $table[users]"; // => This causes the parse
error

echo "Table $table['users']" //=> Parse Error too
echo "Table".$table['users']; //=>OK
$query = "SELECT * from ".$table['users']; //=> OK TOO



[2002-02-22 06:59:46] [EMAIL PROTECTED]

d



[2002-02-22 06:55:12] [EMAIL PROTECTED]

Sounds very strange. Can you do a var_dump() on the sql string?

Can you also test and report back if it works with

  "SELECT * from {$table['users']}"

?



[2002-02-22 06:45:23] [EMAIL PROTECTED]

Here is the code:

error_reporting(E_ALL);
$table  =  array('admin'=> 'md_adm'
,'users'=> 'usuarios'
,'tables'   => 'md_tables'
,'product'  => 'md_prods'
);

if(!connect_mydb()) die("unable to connect or select db");

if(isset($table['users'])) { // => works OK
echo "$table[users] will warn me!"; // => warning
echo "$table['users']"; // => no warning
}

$query = "SELECT * from $table['users']";
$result = mysql_query($query); // => PARSE ERROR!!

//But if I delete the '' in $query it works ok:

$query = "SELECT * from $table[users]";
$result = mysql_query($query); // => Query done!!


According to PHP Manual in Arrays : "Why is $foo[bar] wrong?" the
syntax $foo[bar] is deprecated despite working.

João Paulo M. Fischer





-- 
Edit this bug report at http://bugs.php.net/?id=15673&edit=1




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Open
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

It seems we cannot use the correct syntax $table['users'] inside the
two ""...

This will work:
$result = mysql_query("SELECT * from ".$table['users']);

This wont work:
$result = mysql_query("SELECT * from $table['users']");

This will, but should send a warning and it isnt:
$result = mysql_query("SELECT * from $table[users]");

The errors happens everywere I call any array with the '' or "" like
$table["something"] or $table['something'] inside ""s...


Previous Comments:


[2002-02-22 07:06:12] [EMAIL PROTECTED]

Sorry: The error occurs when we define the $query:

$query = "SELECT * from $table[users]"; // => This causes the parse
error

echo "Table $table['users']" //=> Parse Error too
echo "Table".$table['users']; //=>OK
$query = "SELECT * from ".$table['users']; //=> OK TOO



[2002-02-22 06:59:46] [EMAIL PROTECTED]

d



[2002-02-22 06:55:12] [EMAIL PROTECTED]

Sounds very strange. Can you do a var_dump() on the sql string?

Can you also test and report back if it works with

  "SELECT * from {$table['users']}"

?



[2002-02-22 06:45:23] [EMAIL PROTECTED]

Here is the code:

error_reporting(E_ALL);
$table  =  array('admin'=> 'md_adm'
,'users'=> 'usuarios'
,'tables'   => 'md_tables'
,'product'  => 'md_prods'
);

if(!connect_mydb()) die("unable to connect or select db");

if(isset($table['users'])) { // => works OK
echo "$table[users] will warn me!"; // => warning
echo "$table['users']"; // => no warning
}

$query = "SELECT * from $table['users']";
$result = mysql_query($query); // => PARSE ERROR!!

//But if I delete the '' in $query it works ok:

$query = "SELECT * from $table[users]";
$result = mysql_query($query); // => Query done!!


According to PHP Manual in Arrays : "Why is $foo[bar] wrong?" the
syntax $foo[bar] is deprecated despite working.

João Paulo M. Fischer





-- 
Edit this bug report at http://bugs.php.net/?id=15673&edit=1




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
 Status:   Open
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Sorry: The error occurs when we define the $query:

$query = "SELECT * from $table[users]"; // => This causes the parse
error

echo "Table $table['users']" //=> Parse Error too
echo "Table".$table['users']; //=>OK
$query = "SELECT * from ".$table['users']; //=> OK TOO


Previous Comments:


[2002-02-22 06:59:46] [EMAIL PROTECTED]

d



[2002-02-22 06:55:12] [EMAIL PROTECTED]

Sounds very strange. Can you do a var_dump() on the sql string?

Can you also test and report back if it works with

  "SELECT * from {$table['users']}"

?



[2002-02-22 06:45:23] [EMAIL PROTECTED]

Here is the code:

error_reporting(E_ALL);
$table  =  array('admin'=> 'md_adm'
,'users'=> 'usuarios'
,'tables'   => 'md_tables'
,'product'  => 'md_prods'
);

if(!connect_mydb()) die("unable to connect or select db");

if(isset($table['users'])) { // => works OK
echo "$table[users] will warn me!"; // => warning
echo "$table['users']"; // => no warning
}

$query = "SELECT * from $table['users']";
$result = mysql_query($query); // => PARSE ERROR!!

//But if I delete the '' in $query it works ok:

$query = "SELECT * from $table[users]";
$result = mysql_query($query); // => Query done!!


According to PHP Manual in Arrays : "Why is $foo[bar] wrong?" the
syntax $foo[bar] is deprecated despite working.

João Paulo M. Fischer





-- 
Edit this bug report at http://bugs.php.net/?id=15673&edit=1




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread jpaulomf

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
-Status:   Feedback
+Status:   Open
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

d


Previous Comments:


[2002-02-22 06:55:12] [EMAIL PROTECTED]

Sounds very strange. Can you do a var_dump() on the sql string?

Can you also test and report back if it works with

  "SELECT * from {$table['users']}"

?



[2002-02-22 06:45:23] [EMAIL PROTECTED]

Here is the code:

error_reporting(E_ALL);
$table  =  array('admin'=> 'md_adm'
,'users'=> 'usuarios'
,'tables'   => 'md_tables'
,'product'  => 'md_prods'
);

if(!connect_mydb()) die("unable to connect or select db");

if(isset($table['users'])) { // => works OK
echo "$table[users] will warn me!"; // => warning
echo "$table['users']"; // => no warning
}

$query = "SELECT * from $table['users']";
$result = mysql_query($query); // => PARSE ERROR!!

//But if I delete the '' in $query it works ok:

$query = "SELECT * from $table[users]";
$result = mysql_query($query); // => Query done!!


According to PHP Manual in Arrays : "Why is $foo[bar] wrong?" the
syntax $foo[bar] is deprecated despite working.

João Paulo M. Fischer





-- 
Edit this bug report at http://bugs.php.net/?id=15673&edit=1




Bug #15673 Updated: Quotes crash MySQL queries: $array['val'] = Parse Error, but $array[val] works

2002-02-22 Thread mfischer

 ID:   15673
 Updated by:   [EMAIL PROTECTED]
-Summary:  Quotes crash MySQL queries: $array['val'] = Parse
   Error, but  $array[val] works
 Reported By:  [EMAIL PROTECTED]
-Status:   Open
+Status:   Feedback
 Bug Type: Arrays related
 Operating System: Linux 2.4.5
 PHP Version:  4.1.1
 New Comment:

Sounds very strange. Can you do a var_dump() on the sql string?

Can you also test and report back if it works with

  "SELECT * from {$table['users']}"

?


Previous Comments:


[2002-02-22 06:45:23] [EMAIL PROTECTED]

Here is the code:

error_reporting(E_ALL);
$table  =  array('admin'=> 'md_adm'
,'users'=> 'usuarios'
,'tables'   => 'md_tables'
,'product'  => 'md_prods'
);

if(!connect_mydb()) die("unable to connect or select db");

if(isset($table['users'])) { // => works OK
echo "$table[users] will warn me!"; // => warning
echo "$table['users']"; // => no warning
}

$query = "SELECT * from $table['users']";
$result = mysql_query($query); // => PARSE ERROR!!

//But if I delete the '' in $query it works ok:

$query = "SELECT * from $table[users]";
$result = mysql_query($query); // => Query done!!


According to PHP Manual in Arrays : "Why is $foo[bar] wrong?" the
syntax $foo[bar] is deprecated despite working.

João Paulo M. Fischer





-- 
Edit this bug report at http://bugs.php.net/?id=15673&edit=1