Page 1 of 1

PHP Error

Posted: Thu Feb 12, 2015 5:31 pm
by SpiritWebb
I am attempting to figure out why this code is saying there is an error. Will show the code, then the error. I'm lost...

Code: Select all

<?php
$errorMsg = "";
$combUn = "false";
$hintMsg = "";
?>

<?php
if (isset($_POST['ans_one']))
{
  $ans1 = $_POST['ans_one'];
  $ans2 = $_POST['ans_two'];
  $ans3 = $_POST['ans_three'];
  $ans4 = $_POST['ans_four'];
  $ans5 = $_POST['ans_five'];  <-- Line 15
  
  if ( $ans1 == "VIIXIV" && $ans2 == "TARDIS" && $ans3 == "RIVER SONG" && $ans4 == "STAR DESTROYER" && $ans5 == "SPIDER" )
  {
     $combUn = "true";
  } 
  else
  {
    $errorMsg = '<font color="red">Combination was entered incorrectly, please try again!</font>';
  }
}
?>

<?php

if ($combUn == "false")
{
  $hintMsg = "<b><u><i>Hint:</b></u> What date did we get together?</i>";
}
if ($combUn == "true")
{
  $hintMsg = "<b><u><i>Hint:</b></u> Use a GPS:</i> 29.414558, -98.628156";
}
?>
<title>Combination Hunt</title>

<style>
       body { background-color: lightgray }
       
       .tbl1 { background:#FFFFFF 
               url(box.png) no-repeat 4px 4px;
               padding: 4px 4px 4px 22px;
               height: 25px;
             }
</style>

<center><h1>Combination Hunt</h1></center>
<br>
<center>You must find the correct combination to unlock the final destination</center>
<br><br><br><br><br><br><br><br><br>

<center>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="text" name="ans_one" class="tbl1" size="4" maxlength="3">
<input type="text" name="ans_two" class="tbl1" size="4" maxlength="3">
<input type="text" name="ans_three" class="tbl1" size="4" maxlength="3">
<input type="text" name="ans_four" class="tbl1" size="4" maxlength="3">
<input type="text" name="ans_five" class="tbl1" size="4" maxlength="3">
<br><br><br><br>
<input type="image" name="submit" src="lock.png" length="64" height="64" border="0" alt="submit">
</form>
</center>
<center>
<i>Make sure caps lock is ON when answering questions</i>
<br><br>
<?php
print "$errorMsg";
print "<br>";
print "$hintMsg";
?>
</center>
Line 15: $ans5 = $_POST['ans_five'];

Error: PHP Parse error: syntax error, unexpected ';' in index.php on line 15.

This is hosted on Halls Server. It works on WAMP, but not when uploaded on the server

Re: PHP Error

Posted: Thu Feb 12, 2015 7:16 pm
by a_bertrand
You should check what's on the server exactly... Could be that the upload didn't worked out well.

Re: PHP Error

Posted: Thu Feb 12, 2015 7:27 pm
by SpiritWebb
a_bertrand wrote:You should check what's on the server exactly... Could be that the upload didn't worked out well.
Re-uploaded, that worked. Thanks!

Re: PHP Error

Posted: Fri Feb 13, 2015 7:42 am
by a_bertrand
No problem. Some times odd things happen ;)

Re: PHP Error

Posted: Fri Feb 13, 2015 4:13 pm
by SpiritWebb
a_bertrand wrote:No problem. Some times odd things happen ;)
Yeah, I started to get frustrated. The coding was right, but the error kept throwing me off. Never thought to try a re-upload. This is why I love this community! Again, thanks!