Php Eval Syntax Error Unexpected T_encapsed_and_whitespace
Contents |
here for a quick overview of the site Help Center Detailed answers to any t_encapsed_and_whitespace, expecting t_string or t_variable or t_num_string questions you might have Meta Discuss the workings and policies parse error syntax error unexpected t_encapsed_and_whitespace expecting of this site About Us Learn more about Stack Overflow the company Business Learn more about expecting identifier (t_string) or variable (t_variable) or number (t_num_string) hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow
T_encapsed_and_whitespace Wordpress
is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING up vote 7 down vote favorite I have been staring at this code for hours now and I cannot figure unexpected t_constant_encapsed_string out where my mistake is. I know this syntax error usually comes up because of some missing or out of place curly brace or some issue with single/double quotes and I'm not sure there is one anywhere in my code. I am only trying to fix my syntax right now so I can get the code to completely compile. Any help would be much appreciated. Here is my code:
Please put your comments below.
Name:
Comment:
END; } function process_form() { print "adding comment...
"; $Name = $_POST['WholeName']; $Comment = $_POST['Comment']; if( preg_match("^[a-zA-Z]+$", $Name)) { if( preg_matDetected You currently have javascript disabled. Several functions may not work. Please re-enable javascript to access full functionality. [SOLVED] Syntax error using eval() Started by Johnain, Oct 10 2009 07:25 AM Please log syntax error, unexpected t_variable in to reply 7 replies to this topic #1 Johnain Johnain Advanced Member Members 64
Unexpected T_string
posts Posted 10 October 2009 - 07:25 AM Hi AllI have never used eval() before to generate and execute php code.The code
Heredoc In Php
that I am trying to generate is a varying number of rows that should say (and execute) ... $incomingvariable = $_POST['incomingvariable'] ;... where the incoming variable will be 1_saleprice to (for example ) 10_saleprice when $pricecount http://stackoverflow.com/questions/8400018/syntax-error-unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-vari (see below) has a value of 10The variable $pricecount has a value of 8 with the data I am using and it IS passed correctly (I use EngInSite debugger so I know that).I am using a for loop. The variable that holds the number of incoming records is called $pricecount. It reads like this ...93 for ($z = 1; $z <= $pricecount; $z += 1) 94 {95 $y = https://forums.phpfreaks.com/topic/177174-solved-syntax-error-using-eval/ trim($z) ;96 97 $varval = "$" . $y . "_saleprice = $" . "_POST['" . $y . "_saleprice'] ;" ;9899 eval("\$varval = \"$varval\";");100 }You will see that I have put the terminating executing code semi-colon into the variable $varval in this example and I still get an error with or without it.(I split the $ and the _POST because otherwise it reads it directly as $_POST[')The error WITH the semi colon is ...Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/q07peri/public_html/admin/mdprodcodeedit.php(99) : eval()'d code on line 1The error WITHOUT the closing semi-colon is exactly the same. On my local box windows ...Apache 2.2.9PHP 5.2.-MySQL 5 Back to top #2 Daniel0 Daniel0 Advanced Member Staff Alumni 11,956 posts Posted 10 October 2009 - 07:36 AM Try to echo instead of eval()'ing. In that way it'll be easier to see what the error is. Back to top #3 Johnain Johnain Advanced Member Members 64 posts Posted 10 October 2009 - 07:40 AM Try to echo instead of eval()'ing. In that way it'll be easier to see what the error is. I'll do that. Thanks. On my local box windows ...Apache 2.2.9PHP 5.2.-MySQL 5 Back to top #4 Johnain Johnain Advanced Member Members 64 posts Posted 10 October
me a "unexpected T_ENCAPSED_AND_WHITESPACE" The SitePoint Forums have moved. You can now find them here. This forum is now closed http://www.sitepoint.com/forums/showthread.php?71997-eval()-giving-me-a-quot-unexpected-T_ENCAPSED_AND_WHITESPACE-quot to new posts, but you can browse existing content. You can find out more information about the move and how to open a new account (if necessary) here. If you get stuck you can get support by emailing forums@sitepoint.com If this is your first visit, be sure to check out the FAQ by clicking the link above. syntax error You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. SitePoint Sponsor User Tag List Results 1 to 3 of 3 Thread: eval() giving me a "unexpected T_ENCAPSED_AND_WHITESPACE" Thread Tools Show Printable Version Subscribe to this syntax error unexpected Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Aug 12, 2002,00:01 #1 mitsubishi View Profile View Forum Posts Probably eating pie Join Date Sep 2001 Location England, UK Posts 405 Mentioned 0 Post(s) Tagged 0 Thread(s) eval() giving me a "unexpected T_ENCAPSED_AND_WHITESPACE" I have no idea what this means, I'm getting this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING It basically seems to report an error when I try and use a non-numeric array keys. This works: PHP Code: $taste='Good$lang[1]';
But using these I get the above error. PHP Code:
$lang[1]="morning";
eval("\$taste=\"$taste\";");
echo$taste;
$taste="Good\$lang['one']";
$taste='Good$lang[\'one\']';