Reputation: 6688
I'm working on something like this:
if ($varA != null & $varB = null){
$newthing = "Something else";
}
It doesn't seem to want to work. I've tried &&
for &
but I can find a good reference for these and what they do.
EDIT: Going to try and clear up what my objective is.
I have three if
statement that I want to execute whether or not some variables have value in an encoded URL. Those three statement are:
if ($lprice != null && $hprice == null){
$clauses[] = "MSTLISTPRC >= " . $lprice;
}
if ($hprice != null && $lprice == null)(
$clauses[] = "MSTLISTPRC <= " . $hprice;
}
if ($lprice != null && $hprice != null){
$clauses[] = "MSTLISTPRC BETWEEN " . $lprice . " AND " . $hprice;
}
The final if
statement works, the first two don't. It's something with the PHP code itself because I'm testing it an echo
to just output the query string and when I try to execute this, it fails. I don't know how to apply error handling so I haven't been using that.
Upvotes: 0
Views: 26
Reputation: 37904
if ($varA != null && $varB = null){
$newthing = "Something else";
}
this should be fine..
Upvotes: 1
Reputation: 3830
You need to use && instead of & and == instead of =.
So:
if ($varA != null && $varB == null){
$newthing = "Something else";
}
Upvotes: 4