Jump to content


Photo

Simple Loop Syntax Problem - Please Help!


  • Please log in to reply
1 reply to this topic

#1 stuartbrown20

stuartbrown20
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 14 July 2006 - 04:54 AM

Hey guys, i have this loop which is causing me problems and i'm not sure why. I assume it's a syntax problem but i just can't seem to identify the issue. Can anyone help me pleaaase!!!!

<?php
for($i = 0; $i < 20); $i++) {
?>
	<input type="hidden" name="suburb<?php echo $i; ?>" value="<?php echo $_POST['suburb$i']; ?>" />
<?php
}
?>


#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 14 July 2006 - 05:38 AM

You have a right parenthesis after the 20, and you're using single quotes in the $_POST array key. Try:

for ($i = 0; $i < 20; $i++) {
    echo '<input type="hidden" name="suburb', $i, '" value="', $_POST["suburb$i"], '" />';

}

While testing/debugging this, make sure you have error_reporting(E_ALL); at the top of your script so you can see all of PHP's errors/warnings/notices. Also, have display_errors on in the php.ini file. Otherwise, set it using ini_set('display_errors', '1'); at the top of your script too.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users