stuartbrown20 Posted July 14, 2006 Share Posted July 14, 2006 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!!!![code]<?phpfor($i = 0; $i < 20); $i++) {?> <input type="hidden" name="suburb<?php echo $i; ?>" value="<?php echo $_POST['suburb$i']; ?>" /><?php}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14560-simple-loop-syntax-problem-please-help/ Share on other sites More sharing options...
toplay Posted July 14, 2006 Share Posted July 14, 2006 You have a right parenthesis after the 20, and you're using single quotes in the $_POST array key. Try:[code]for ($i = 0; $i < 20; $i++) { echo '<input type="hidden" name="suburb', $i, '" value="', $_POST["suburb$i"], '" />';}[/code]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. Quote Link to comment https://forums.phpfreaks.com/topic/14560-simple-loop-syntax-problem-please-help/#findComment-57781 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.