Jump to content

Parse Error


Bionicjoe

Recommended Posts

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 }

?>

Link to comment
https://forums.phpfreaks.com/topic/152442-parse-error/
Share on other sites

<?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
}
?>

Link to comment
https://forums.phpfreaks.com/topic/152442-parse-error/#findComment-800601
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.