PHP Error

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

PHP Error

Post 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
Image

Image
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: PHP Error

Post by a_bertrand »

You should check what's on the server exactly... Could be that the upload didn't worked out well.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Error

Post 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!
Image

Image
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: PHP Error

Post by a_bertrand »

No problem. Some times odd things happen ;)
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Error

Post 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!
Image

Image
Post Reply

Return to “Beginner Help and Support”