thefonz22 Posted May 1, 2013 Share Posted May 1, 2013 Simple question, I want to add an OR statement to the example below. I can't remember what the syntax is. if($ref !== 'http://www.example.com/prestige/') { die("Hotlinking not permitted"); } echo "Successful Login!"; Why wont this work? This is how I'm trying to do my OR statement with 2 URL's. if($ref !== 'http://www.example.com/prestige/') || ($ref !== 'http://www.example2.com/prestige/') { die("Hotlinking not permitted"); } echo "Successful Login!"; Please help! Thanks in advance. Quote Link to comment Share on other sites More sharing options...
litebearer Posted May 1, 2013 Share Posted May 1, 2013 If you use OR the test will fail - ie if one is good and one is bad, OR both are bad , it will produce fail If you use AND then both conditions must be bad for it to produce fail Soooo. if($a !== $b AND $a !== $c) {then do something }else{do something else} Quote Link to comment Share on other sites More sharing options...
lemmin Posted May 1, 2013 Share Posted May 1, 2013 All the conditions should be wrapped inside the same set of parentheses: if($ref !== 'http://www.example.com/prestige/' || $ref !== 'http://www.example2.com/prestige/') { die("Hotlinking not permitted"); } HOWEVER, since you are negating both sides of the OR, this statement will ALWAYS evaluate to false. So, as litebearer suggested, you want to change to and AND: if($ref !== 'http://www.example.com/prestige/' && $ref !== 'http://www.example2.com/prestige/') { die("Hotlinking not permitted"); } Quote Link to comment Share on other sites More sharing options...
thefonz22 Posted May 1, 2013 Author Share Posted May 1, 2013 If you use OR the test will fail - ie if one is good and one is bad, OR both are bad , it will produce fail If you use AND then both conditions must be bad for it to produce fail Soooo. if($a !== $b AND $a !== $c) {then do something }else{do something else} Thanks! Worked a treat. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.