Parse error: syntax error, unexpected '{' in C:\wamp\www\login.php on line 13

5 replies
I'm trying to create a register/login script, following a tutorial, but I can't seem to understand why I'm getting this error. My code is the same as the tutorial's, but he doesn't get an error and I do.

<?php
include 'core/init.php';

if (user_exists('ji') === true) {
echo 'exists';
}
die();

if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];

if (empty($username) === true || empty($password) === true {
$errors[] = 'You need to enter a username and password';
} else if (user_exists($username) === false) {
$errors[] = 'We can\'t find that username. Have you registered?';
}
}
?>
PHP Tutorials: Register & Login (Part 5): User Login (Part 2) - YouTube
#error #parse #syntax #unexpected
  • Profile picture of the author David Beroff
    The error in the thread title pretty much says everything you need: The if statement on line 13 is never closed (with a closing parenthesis) before that '{'.

    I didn't look at the video that you reference, but I'm guessing this is likely a great example of why video tutorials should point to web pages where sample code can be mechanically copied/pasted, rather than doing so by hand.
    Signature
    Put MY voice on YOUR video: AwesomeAmericanAudio.com
    {{ DiscussionBoard.errors[8333185].message }}
  • Profile picture of the author Complexity
    Hm, I swear I looked over it several times and didn't notice that. Also, I would prefer to actually learn what's happening opposed to copy and pasting pieces of code.
    {{ DiscussionBoard.errors[8333193].message }}
    • Profile picture of the author David Beroff
      Oh, there's absolutely nothing wrong with understanding the code, but that doesn't mean that it needs to be typed in manually.

      BTW, I just happen to be reviewing Accountify tonight with the intent of possibly using it to manage Member accounts for AboutTh.is, (so it's kinda ironic that you are reviewing a similar solution). The Pear:: DB interface would have to be upgraded to PDO, but that's not too bad. I was originally considering outsourcing that part, but I'm trying to learn more about PDO, so I'll probably just do the conversion myself.
      Signature
      Put MY voice on YOUR video: AwesomeAmericanAudio.com
      {{ DiscussionBoard.errors[8333212].message }}
  • Profile picture of the author Complexity
    I find that I learn best when I type it all out myself so I can see what's going on. I guess it's personal preference.

    I'll have a look later. :] I don't want to get sidetracked too much until this login system works.
    {{ DiscussionBoard.errors[8333222].message }}

Trending Topics