Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VERY simple question =)

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
GB
Hi,

This is gonna sound really silly - but its been a hell of a long time since I coded any PHP. I'm trying to make a minor modification to an existing script, using:

if ($xcatid == 5 || $xcatid == 7)

...but that doesn't seem to be working.

Whats the right format for "or" in PHP? :/

TIA!

Andy
 
That's correct.

If xcatid is equal to 5 OR xcatid is equal to 7 then...

If it's not working then something else is wrong

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Hi,

Mmm.. odd. I was thinking maybe it was just my Perl coding kicking in <G>

I'll do a little more debugging, and see if I can spot where the problem is :)

Thanks =)

Andy
 
try an echo of the $xcatid variable before the test i.e
Code:
echo $xcatid;
 
Hi,

Ya, it turned out it was just me being an idiot :p

I was trying to access a page where $xcatid didn'te exist (even though it was being passed in, so guess it was just something to do with the script itself, and how it works)

I tried it on a sub-category (instead of a top-level cat), and it worked fine =)

Cheers

Andy
 
Sounds like you, quite rightly, have register_globals off.
This means that any variable passed to the script from another script must be specifically 'retrieved'.

For instance, if your script is called via the URL myscript.php?xcatid=7 then xcatid will not be available to myscript.php unless you first do:

Code:
$myvar = $_GET['xcatid'];

The value of xcatid is then available as myvar. (You can still call it $xcatid if you prefer)

It's a similar situation with POSTed data.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Hi,

Yeah, I believe that is the case - however, its all working fine now - so I'm just gonna leave it now <G> (don't mess with stuff unless it breaks ;))

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top