Page 3 of 3

Posted: Tue Aug 30, 2005 1:16 am
by dude81
Or is it that I should name it as to[]{$i} or to[{$i}]

Posted: Tue Aug 30, 2005 1:17 am
by n00b Saibot
because it should be echo $_POST['to'.$i].

Look we never use {} outside of "" to print a variable. This construct is only applicable inside "". So correct it and then tell us.

Posted: Tue Aug 30, 2005 1:33 am
by dude81
<?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

Posted: Tue Aug 30, 2005 1:45 am
by n00b Saibot
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...

Posted: Tue Aug 30, 2005 1:56 am
by dude81
:wink: thanks, but y is it not getting called in the other form
I call it like this. it doesnt echo the email. whats the msitake im doing here
for($i=1;$i<=10;$i++)
{
$email=$_POST['to'.$i];
echo $email;
{
//some operations;
}
}

Posted: Tue Aug 30, 2005 2:08 am
by n00b Saibot
Do you have this app online somewhere so that we can see it or else for debugging put print_r($_POST) on the top of your page and see that all the vars are set properly.

Posted: Tue Aug 30, 2005 2:19 am
by dude81
No I dont have it online. I was given this to develop it. but gr8 it is getting everything I could see those post variables coming in this fashion.
Array([to{_1}]=> value1 [to{_2}]=> value2...).
but the same array repeating 10 times. So it is getting underscore

Posted: Tue Aug 30, 2005 2:28 am
by n00b Saibot
Why does the index have an underscore & why are the braces there ?? Please Post the output as it is and please use the code/php tags to post the code/php segments.

Posted: Tue Aug 30, 2005 2:37 am
by dude81
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

Posted: Tue Aug 30, 2005 2:46 am
by n00b Saibot
So the problem was not entirely with the processing code. it was also in the submitting form too. well, you got it right so continue. Tell us again when you have a prob. ;)

Posted: Tue Aug 30, 2005 4:08 am
by dude81
ok sure
thank u for the help