From: [EMAIL PROTECTED]
Operating system: Linux 2.4.5
PHP version: 4.1.1
PHP Bug Type: Arrays related
Bug description: Quotes crash MySQL queries: $array['val'] = Parse Error, but
$array[val] works
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 bug report at http://bugs.php.net/?id=15673&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=15673&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=15673&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=15673&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=15673&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15673&r=support
Expected behavior: http://bugs.php.net/fix.php?id=15673&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=15673&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=15673&r=submittedtwice