-2

so this is my code but it gives an unexpected '{' on line 50, can someone just double check this for me? The box on my site just disappears and I have run this through a few phrases and they picked an unexpected '{' on line 31 as well.

I'm not sure if I'm just not seeing it but id appreciate the help

CODE

<?php
if(isset($_POST['signup'])){
$screenName = $_POST['screenName'];
$password = $_POST['password'];
$email = $_POST['email'];
$error = '';

if(empty($screenName) or empty($password) or empty($email)){
$error = 'All fields are required!';
}else{
$email = $getFromU->checkInput($email);
$screenName = $getFromU->checkInput($screenName);
$password = $getFromU->checkInput($password);

if(!filter_var($email)){
  $error = 'Invalid email format';
}else if(strlen($screenName) > 20){
  $error = 'Name must be between 6-20 caracters long';
}else if(strlen($password) < 5){
  $error = 'Password is too short';
}else{
  if($getFromU->checkEmail($email) === true){
    $error = 'Email already in use';
  }else{

  }
  }
 }
}
?>

<form method="post">
<div class="signup-div">
<h3>Sign up </h3>
<ul>
    <li>
        <input type="text" name="screenName" placeholder="Full Name"/>
    </li>
    <li>
        <input type="email" name="email" placeholder="Email"/>
    </li>
    <li>
        <input type="password" name="password" placeholder="Password"/>
    </li>
    <li>
        <input type="submit" name="signup" Value="Signup for SocialBud">
    </li>
    </ul>
    <?php
    if(isset($error){
    echo '<li class="error-li">
          <div class="span-fp-error">'.$error.'</div>
         </li>';
     }
    ?>

    </div>
    </form>
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
r.kuypers
  • 7
  • 6

1 Answers1

0

The issue is here:

<?php
if(isset($error){   //<--Missing ")"
echo '<li class="error-li">
      <div class="span-fp-error">'.$error.'</div>
     </li>';
 }
?>

It should be

<?php
if(isset($error)){   <--Missing ")"
echo '<li class="error-li">
      <div class="span-fp-error">'.$error.'</div>
     </li>';
 }
?>

The parser isn't finding the missing ) until it reaches the unexpected { without having closed the if, so that's why it throws that particular error.

TFrazee
  • 792
  • 6
  • 20
  • 1
    When the answer is "add one missing parenthesis", there is no need to answer. Just leave a comment under the question and flag/vote to close as Off-topic: Typo. This page will be quickly scrubbed from the site (as will any upvote points you receive) because this page is completely useless to researchers. – John Conde May 18 '18 at 15:56