Link to home
Start Free TrialLog in
Avatar of tjyoung
tjyoung

asked on

Can't find what is wrong with my syntax using an if statement in a query

Can someone see what is wrong with my syntax (it may be completely obvious or for some reason impossible to do. I'm not particularly good at this)

I'm trying to say more or less:
if the Session variable: switch_user_id has a value, use it, otherwise use the session variable user_id value instead. Below is part of a constructed query using datatables.net.

$sWhere .= " AND subscribers.account_id=".
if (isset($_SESSION['switch_user_id']))
{ 
$_SESSION['switch_user_id'];
} else { 
$_SESSION['user_id'];
};

Open in new window


I am using session_start(); at the top of my page.
Get this error in my logs:
PHP Parse error: syntax error, unexpected T_IF
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tjyoung
tjyoung

ASKER

much nicer. Thanks!