Chris Hayes wrote:
Let me explain.
For one, the single quotes are not in the way here because the query
is written between double quotes.
Then, leaving out the single quotes like Marek suggests will only work
because PHP is too programmer-friendly.
But the indexes of such arrays should always be quoted, because they
are strings, and not the name of 'constant' values.
But it is within string (double quotes), so the index evaluates as a
string, not as a constant.
If you do not quote them PHP will first try to look up whether you
defined id somewhere, as a constant (with define ('id','value');).
Which you did not, so PHP will fail to find it. Only then PHP will
gently assume that since there is no constant defined with the name
id, that you meant 'id'. Valuable processing time wasted for no reason.
Set error_reporting to ~E_ALL if you do not believe me.
I believe you, but try it first:
<?php
$a=array('id'=> 'Hello world');
echo "$a[id]";
?>
<?php
$a=array('id'=> 'Hello world');
echo "$a['id']";
?>
this is *different*:
<?php
$a=array('id'=> 'Hello world');
echo $a[id];
?>
<?php
$a=array('id'=> 'Hello world');
echo $a['id'];
?>
I would support the $_POST suggestion by Jason.
He got error from php and not mysql,
Suggested reading: the 'PHP Bible'.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php