[SOLVED] unexpected T_ENCAPSED_AND_WHITESPACE,
Moderator: General Moderators
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
<?php for($i=1;$i<=10;$i++)
{
echo $_POST['to'.$i];
echo "<input type=\"hidden\" name=\"to{.$i}\" value=\"{$_POST['to'.$i]}\">";
if(isset($_POST['to'.$i]))
{
echo "<br>";
echo "$_POST['to'.$i]";
}
else
{
echo "not set";
}
}
?>
This results in parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
{
echo $_POST['to'.$i];
echo "<input type=\"hidden\" name=\"to{.$i}\" value=\"{$_POST['to'.$i]}\">";
if(isset($_POST['to'.$i]))
{
echo "<br>";
echo "$_POST['to'.$i]";
}
else
{
echo "not set";
}
}
?>
This results in parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Oh boy! You are again making same mistake. See the difference...
On Line #3 -> echo $_POST['to'.$i];
On Line #8 -> echo "$_POST['to'.$i]";
#3 doesn't use "". I've told you before, use {} when printing a var inside of "".
And please use PHP tags, comply to the forum rules or else you will get a serious warning...
On Line #3 -> echo $_POST['to'.$i];
On Line #8 -> echo "$_POST['to'.$i]";
#3 doesn't use "". I've told you before, use {} when printing a var inside of "".
And please use PHP tags, comply to the forum rules or else you will get a serious warning...
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Hey got it
u know how to call it
email=$_POST['to_{'.$i.'}'].
so complex.. or is it wrong... But where we are changing it to underscore
Any how output is here
<?php
Array ( [to{_1}] => value1 [to{_2}] => value2 [to{_3}] => value3 [to{_4}] => value4 [to{_5}] => value5 [to{_6}] => value6 [to{_7}] => value7 [to{_8}] => value8 [to{_9}] => value9 [to{_10}] => value10 [message_header] => [message_footer] => [send] => Send this card )
?>
repeating the array 10 times
u know how to call it
email=$_POST['to_{'.$i.'}'].
so complex.. or is it wrong... But where we are changing it to underscore
Any how output is here
<?php
Array ( [to{_1}] => value1 [to{_2}] => value2 [to{_3}] => value3 [to{_4}] => value4 [to{_5}] => value5 [to{_6}] => value6 [to{_7}] => value7 [to{_8}] => value8 [to{_9}] => value9 [to{_10}] => value10 [message_header] => [message_footer] => [send] => Send this card )
?>
repeating the array 10 times
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact: