0

I get an error when I try to check if a query taken from the url equals something.

Error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')'

if (isset($_GET['lang'] == 'eng')) {
    echo 'ENG';
}else if (isset($_GET['lang'] == 'alb')) {
    echo 'ALB';
}else {
    echo 'MKD';
}

Am I doing something wrong?

Thanks

Nikk
  • 7,384
  • 8
  • 44
  • 90

1 Answers1

3

You can not use == and isset to gether:

if (isset($_GET['lang']) && $_GET['lang']=='eng') {
    echo 'ENG';
}
else if (isset($_GET['lang']) && $_GET['lang'] == 'alb') {
    echo 'ALB';
}else {
    echo 'MKD';
}
RNK
  • 5,582
  • 11
  • 65
  • 133
  • Additionally, PHP uses "elseif" not "else if" – Bryan Zwicker May 15 '15 at 19:37
  • I am getting an error, **syntax error, unexpected ')'**, in the first line. What is causing that? – Nikk May 15 '15 at 19:39
  • @Boris: Try to use above code. Let us know if there is any problem with that. – RNK May 15 '15 at 19:40
  • @Ronak Ah, you can. I was thinking of the limitation if you don't use curly braces. My bad :) Boris, The syntax error is because the isset should be closed before the && and there is an extra ) at the end of the if – Bryan Zwicker May 15 '15 at 19:41
  • @RonakPatel I copied and pasted the code above. Thats the error I get... – Nikk May 15 '15 at 19:41
  • @Boris: Oh. sorry.. There was 1 extra closing bracket.. Now try it – RNK May 15 '15 at 19:42