1

Me and my mate we're trying to solve this for over 1.5 hours, we are still getting the same and tried almost everything we could.

Could anyone help us do that?

This is error what we're getting:

PHP Parse error: syntax error, unexpected '}', expecting ',' or ';' in

And this is the code (line) it's happening on:

if(!isset($_POST['name'])) {echo"Please fill in a valid username"} else {$ok="$ok+1"}

It's PHP.

If anyone wants the full code here it is:

$ok=0;
if(isset($_POST['submit'])) {
if(!isset($_POST['name'])) {echo"Please fill in a valid username"} else {$ok="$ok+1"}
if(!isset($_POST['pass'])) {echo"Please fill in a valid password"} else {$ok="$ok+1"}

if($ok==2){
switch($_POST['name'],$_POST['pass']){
    case "FORAEROND","FORAEROND2":


    THIS IS THE TEXT THAT WILL SHOW IF USERNAME IS 'FORAEROND' AND PASSWROD IS 'FORAEROND2'


    break;



    /*case "FORAEROND5","FORAEROND6";        KEEP FOR LATER

    THIS IS THE TEXT THAT WILL SHOW IF USERNAME IS 'FORAEROND5' AND PASSWROD IS 'FORAEROND6'


    break;
    */

    }
  }
}

Thanks to everyone who will help. :)

EDIT:

We apologize to everyone, it was really stupid, somehow we deleted or forgot ';' behind the codes, this is really stupid and awkward.

2
  • else {$ok="$ok+1"} add ; else { $ok="$ok+1" ; }
    – Dave
    Commented Nov 22, 2016 at 13:07
  • you forgot to add ; (semicolon) after echo. add semicolon and your error gets solved Commented Nov 22, 2016 at 13:07

3 Answers 3

12

You missed ;. Each statement must ends up with a semicolon in PHP.

5

You missed Semicolumn(;)

Replace

if(!isset($_POST['name'])) {echo"Please fill in a valid username"} else {$ok="$ok+1"}

with

if(!isset($_POST['name'])) {echo"Please fill in a valid username"; } else {$ok="$ok+1"; }
1
  • In my case I had an open brace ( that I had forgotten to close with a ) closing brace.
    – Joseph
    Commented May 7, 2020 at 8:58
3
$ok="$ok+1"

you forgot a semicolon here, it should be:

$ok="$ok+1";

same goes for the others

Not the answer you're looking for? Browse other questions tagged or ask your own question.