Bionicjoe Posted April 3, 2009 Share Posted April 3, 2009 I'm missing something simple here, but I keep getting Parse error: syntax error, unexpected T_ELSE in /var/www/palindromes.php on line 28 All the semicolons, etc. look right to me. <?php if (isset($_GET["string"])) { $s = $_GET["string"]; if (strlen($s) > 20) { ?> <p>Oh my! Your string is too big. <?php } elseif (strrev($s) == $s) { echo "$s"; } else { unset ($s); } } ?> <br /> <a href='palindromes.php'>Try Again</a> <?php else { ?> <form action="palindromes.php" method="GET"> Your String: <input type="text" name="string" /> <input type="Submit" value="Submit"/> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/152442-parse-error/ Share on other sites More sharing options...
MadTechie Posted April 3, 2009 Share Posted April 3, 2009 <?php else { //else to what ?> <form action="palindromes.php" method="GET"> EDIT: maybe this will help! <?php if (isset($_GET["string"])) { $s = $_GET["string"]; if (strlen($s) > 20) { ?> <p>Oh my! Your string is too big. <?php }elseif (strrev($s) == $s){ echo "$s"; }else { unset ($s); } }//EDIT#2: either move this down ?> <br /> <a href='palindromes.php'>Try Again</a> <?php else {//else to what ? EDIT#2: OR move this up but they should be together! ?> <form action="palindromes.php" method="GET"> Your String: <input type="text" name="string" /> <input type="Submit" value="Submit"/> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/152442-parse-error/#findComment-800601 Share on other sites More sharing options...
Maq Posted April 3, 2009 Share Posted April 3, 2009 Your error refers to line 28, but you only have 26 lines of code... Quote Link to comment https://forums.phpfreaks.com/topic/152442-parse-error/#findComment-800611 Share on other sites More sharing options...
Bionicjoe Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks, MadTechie. The } was out of position. @Maq: The difference in the number of lines of code is because there are a few lines of html I left out of the sample at the top. Quote Link to comment https://forums.phpfreaks.com/topic/152442-parse-error/#findComment-800633 Share on other sites More sharing options...
MadTechie Posted April 3, 2009 Share Posted April 3, 2009 Coolie Can you click solved Quote Link to comment https://forums.phpfreaks.com/topic/152442-parse-error/#findComment-800724 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.