PHP 'If' not working [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
Basically I am trying to check if a variable is equal to 5, and then echo something if it is, but I get this error.
PHP Code
if ($adminlevel) === '5' {
echo 'user is owner';
}
Error
Parse error: syntax error, unexpected '===' (T_IS_IDENTICAL) in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\Portfolio -- Website\forum\index.php on line 12

if ($adminlevel === '5') {
echo 'user is owner';
}
Move the paren to include the entire statement.

Related

( ! ) Parse error: syntax error, unexpected '{' in D:\Yatharth Files\wamp\www\index.php on line 121 [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
Why does this code throw an error?
<?php
if(isset($_POST['aca'])){
header("location:Academic");
}elseif(isset($_POST['ed'])){
header("location:EnjoyDev");
}elseif(isset($_POST['hb'])){
header("location:Hoverboard");
}elseif(isset($_POST['lc'])){
header("location:LiveChat");
}elseif(isset($_POST['mp']){
header("location:myPro");
}elseif(isset($_POST['ym'])){
header("location:YatMath");
}
?>
LINE 121: }elseif(isset($_POST['mp']){
I didn't miss any semicolons.
LINE 121:
}elseif(isset($_POST['mp']){
should be
} elseif( isset($_POST['mp']) ) {
Also, I would suggest that you make use of spaces to improve your codes' readability. You wouldn't have made this mistake then.

Show page if mysql value is met [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
I'm fairly new to PHP, and I don't know a lot about it. I have had a go, but I don't know where I have gone wrong.
The code:
<?php
include('config.php');
if(isset($_SESSION['username']) and $_SESSION['moderator'] {
} else {
header("location:noaccess.php");
}
?>
The error: Parse error: syntax error, unexpected '}' in E:\LocalWebHost\htdocs\forum\test.php on line 4
<?php
include('config.php');
if(isset($_SESSION['username']) and $_SESSION['moderator']) {
} else {
header("location:noaccess.php");
}
?>
In line 3, your if statement needs closing ).

multidimensional arrays in php with parse error [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
<?php
array $food= array('healthy'=>
array('Salad','Vege',Pasta'),
'unhealthy'=>
array('pizza','icecream'));
echo $food['unhealthy'][1];
?>
i am writing this code but getting this error on browser:
error : Parse error: syntax error, unexpected '$food' (T_VARIABLE),
expecting '(' in C:\xampp\htdocs\foreach.php on line 2
Remove array at the starting and also there is missing single quote before Pasta.
Try this
<?php
$food = array(
'healthy'=> array('Salad', 'Vege', 'Pasta'),
'unhealthy'=> array('pizza', 'icecream')
);
echo $food['unhealthy'][1];
?>

Syntax error,unexpected T_BOOLEAN_OR [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
help me with this..kindly stuck on this for hours
if(!isset($_SESSION['username']) || $_SESSION['user_type'] !='admin')||(!isset($_SESSION['username']) || $_SESSION['user_type'] !='user'){ // if session variable "username" does not exist.
header("location:index.php?msg=Sila%20log%20masuk%20untuk%20mengakses&type=error");
}
When I logged in as admin, it was working. But it keep show me this error when I logged as user
Parse error: syntax error, unexpected T_BOOLEAN_OR in C:\xampp\htdocs\cubaan\init.php on line 4
Can you guys help me with this
Try it
<?php
if((!isset($_SESSION['username']) || $_SESSION['user_type'] !='admin')||(!isset($_SESSION['username']) || $_SESSION['user_type'] !='user')){ // if session variable "username" does not exist.
}
header("location:index.php?msg=Sila%20log%20masuk%20untuk%20mengakses&type=error");
?>

Parse error: unexpected end of the file, can't find it [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
i'm trying to fix a error, i maked a little search and they send that was something because { or } not closed propely, but i can't find it.
The code is this one:
Parse error: syntax error, unexpected end of file in /movies.php on line 176
the code https://gist.github.com/anonymous/258531c7a81517c47de5
Line 167, close your else statement
<?php $active = get_option('widget_single'); if ($active == "true") { dynamic_sidebar( 'Single Movie' ); } else { ?>
<?php $activar_ads = get_option('activar-anuncio-300-250'); } if ($activar_ads == "true") ?>

Categories