0

I am creating a signup page and this error comes up in error log file every time I try to signup on the website.

Any ideas whats wrong here ? (code is below)

PHP Parse error: syntax error, unexpected token ";" in /opt/lampp/htdocs/projectphp/includes/functions.inc.php on line 6

Also I noticed that my text editor (sublime text) doesn’t highlight any variables except for the ones on line 3. Is that normal?

<?php

function emptyInputSignup($name, $surname, $email, $pwd, $pwdRepeat) {
    $result;
    if (empty($name) || (empty($surname) || (empty($email) || (empty($pwd) || (empty($pwdRepeat)) {
        $result = true;
    }
    else {
        $result = false;
    }
    return $result;
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
sauvignon
  • 21
  • 4
  • 2
    Too many `(` without their corresponding `)` – dazed-and-confused Mar 24 '21 at 20:45
  • Your `if` line has more `(`s than `)`s. This makes the line seem incomplete, which means PHP thinks the next line may also be part of that line, and is then confused when it ends abruptly (or so it sees it). – ADyson Mar 24 '21 at 20:46
  • `my text editor (sublime text) doesn’t highlight any variables except for the ones on line 3`...probably because the above syntax error makes everything after that completely incomprehensible to it. It can only parse the code as well as the PHP interpreter can. But I'd have hoped that a) it can match pairs of brackets for you and b) such highlighting as there is might have helped you to spot where the problem was. Or perhaps its highlighting isn't that great anyway - I'm not familiar with that editor specifically. – ADyson Mar 24 '21 at 20:48
  • Imo its best not to abstract this check into a function because you will want other checks too, like min/max length plus things like valid email checks, but if you really want it, then make it more generic and reusable https://3v4l.org/R996v or don't bother – Lawrence Cherone Mar 24 '21 at 21:19

0 Answers0