rubygirl Posted December 27, 2004 Share Posted December 27, 2004 hello anyone!! I am customizing a shop - MS2.2 and for whatever reason i am running into a very simple problem with an if/else statement - BEGIN CODE ----------------------------------------- <?php if ($HTTP_GET_VARS['cPath'] >= 2){ include (DIR_WS_INCLUDES . 'shop.php'); } elseif ($HTTP_GET_VARS['cPath'] = 1){ include (DIR_WS_INCLUDES . 'pchelp.php'); } else { include (DIR_WS_INCLUDES . 'sites.php'); } ?> END CODE ------------------------------------ what i am trying to get this code to do is this: if http://www.domain.com/index.php?cpath=2 then display shop.php else if http://www.domain.com/index.php?cpath=1 then display pchelp.php else display sites.php which would need to work if the url displayed was simply http://www.domain.com/index.php so the first 2 pieces of the if stmt work - if cpath=2 - works fine if cpath=1 - works fine but the else stmt for index.php still displays the same as cpath=1 i know this is probably really simply - but after hours of starring - i am convinced i know nothing about php anymore!!! please help!!! thanks for any help offered! Link to comment Share on other sites More sharing options...
stevel Posted December 27, 2004 Share Posted December 27, 2004 Try using '2' and '1'. Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
rubygirl Posted December 27, 2004 Author Share Posted December 27, 2004 thanks steve - unfortunately that didn't make a difference - what's so strange is like i said before - the 1st 2 statements work fine - i must be calling the last else statement incorrectly ... is there another way to call domain.com/index.php?cpath=2 than the way i am calling it - $HTTP_GET_VARS['cPath'] >= 2? the only problem i have left is that when i want it to do nothing - the last else stmt - it is still displaying the elseif statment instead.... so confused!! thanks for trying steve. Link to comment Share on other sites More sharing options...
alchemywd Posted December 27, 2004 Share Posted December 27, 2004 thanks steve - unfortunately that didn't make a difference - what's so strange is like i said before - the 1st 2 statements work fine - i must be calling the last else statement incorrectly ... is there another way to call domain.com/index.php?cpath=2 than the way i am calling it - $HTTP_GET_VARS['cPath'] >= 2? the only problem i have left is that when i want it to do nothing - the last else stmt - it is still displaying the elseif statment instead.... so confused!! thanks for trying steve. <{POST_SNAPBACK}> Do you mind if i give it a try... what is the url? ========= Thanks, William. Link to comment Share on other sites More sharing options...
rubygirl Posted December 27, 2004 Author Share Posted December 27, 2004 just PM you thanks! Link to comment Share on other sites More sharing options...
Guest Posted December 27, 2004 Share Posted December 27, 2004 hello anyone!! I am customizing a shop - MS2.2 and for whatever reason i am running into a very simple problem with an if/else statement - BEGIN CODE ----------------------------------------- <?php if ($HTTP_GET_VARS['cPath'] >= 2){ include (DIR_WS_INCLUDES . 'shop.php'); } elseif ($HTTP_GET_VARS['cPath'] = 1){ include (DIR_WS_INCLUDES . 'pchelp.php'); } else { include (DIR_WS_INCLUDES . 'sites.php'); } ?> END CODE ------------------------------------ what i am trying to get this code to do is this: if http://www.domain.com/index.php?cpath=2 then display shop.php else if http://www.domain.com/index.php?cpath=1 then display pchelp.php else display sites.php which would need to work if the url displayed was simply http://www.domain.com/index.php so the first 2 pieces of the if stmt work - if cpath=2 - works fine if cpath=1 - works fine but the else stmt for index.php still displays the same as cpath=1 i know this is probably really simply - but after hours of starring - i am convinced i know nothing about php anymore!!! please help!!! thanks for any help offered! <{POST_SNAPBACK}> Okay, I really don't know anything, but what if the line that reads: if ($HTTP_GET_VARS['cPath'] >= 2){ was changed to: if ($HTTP_GET_VARS['cPath'] = 2){ Link to comment Share on other sites More sharing options...
stevel Posted December 28, 2004 Share Posted December 28, 2004 Oh, I see. You want == not =. Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Guest Posted December 28, 2004 Share Posted December 28, 2004 Oh, I see. You want == not =. <{POST_SNAPBACK}> Yes, == Good catch Link to comment Share on other sites More sharing options...
rubygirl Posted December 28, 2004 Author Share Posted December 28, 2004 Oh, I see. You want == not =. <{POST_SNAPBACK}> THANK YOU THANK YOU THANK YOU!!!!! I knew it was something simple - now it works like it should!! did i mention THANK YOU???? Link to comment Share on other sites More sharing options...
stevel Posted December 28, 2004 Share Posted December 28, 2004 You're welcome. I'm annoyed with myself that I didn't spot it the first time around. Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Guest Posted December 28, 2004 Share Posted December 28, 2004 Keep in mind that if you have nested categories then the code will not function as expected (since cPath will eventually be an array). Also, I would suggest using a switch instead of if/else statements...of course, this is my personal preference and your mileage may vary. Bobby Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.