Forum Moderators: coopster

Message Too Old, No Replies

Quick Question About OR ¦¦

         

shadowpwner

8:15 pm on Aug 16, 2009 (gmt 0)

10+ Year Member



Hey, just a quick question about why this script doesn't work:

<?
$ref = strtoupper($_SERVER['HTTP_REFERER']);
if (strpos($ref,"EXAMPLE1") ¦¦ (strpos($ref,"EXAMPLE2")) {
echo "you're from ex";
} else {
echo "you're not from ex";
}
?>

On this line,


if (strpos($ref,"EXAMPLE1")) {

if I remove ¦¦ (strpos($ref,"EXAMPLE2"), it works fine. However, when I add that, I get

Parse error: syntax error, unexpected '{'

Thanks in advance for your help.

StoutFiles

8:46 pm on Aug 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if (strpos($ref,"EXAMPLE1") ¦¦ (strpos($ref,"EXAMPLE2"))

You're missing a ')' at the end

if (strpos($ref,"EXAMPLE1") ¦¦ (strpos($ref,"EXAMPLE2")))

leadegroot

8:47 pm on Aug 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if (strpos($ref,"EXAMPLE1") ¦¦ (strpos($ref,"EXAMPLE2")) {

the first strpos has a bracket to its left to start the if enclosure.
the 2nd strpos also has one - but it plays no purpose and is not closed.
Either add another round bracket on the end of the if enclosure or remove the one immediately preceding the second strpos.

You get better at spotting these things with time :)

penders

10:39 pm on Aug 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You get better at spotting these things with time :)

Many code editors (such as Notepad++) will highlight matches brackets as you type - very handy in complex expressions.