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!<br>"; // => 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

Reply via email to