Re: Register Globals

From: Date: Sat, 05 Nov 2005 02:24:32 +0000
Subject: Re: Register Globals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-225120@lists.php.net to get a copy of this message
mail($to, stripslashes($_POST["subject"]), wordwrap($_POST["message"], 60), "From: $_POST["from"]\r\n"); and I get: Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www-html/emailer/index.html on line 41
The use of $var['index'] or $var["index"] ($_POST['from'], $_GET["to"], etc.) within double quotation marks is causing the problem. To fix this, wrap the whole construct in curly braces: mail($to, stripslashes($_POST["subject"]), wordwrap($_POST["message"], 60), "From: {$_POST["from"]}\r\n"); You only have to do this within other quotation marks and only if the array's index is a string. Hope that helps, Larry

« previous php.general (#225120) next »