Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

why won't this code piece work?


rubygirl

Recommended Posts

Posted

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!

Posted

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.

Posted
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.

Do you mind if i give it a try... what is the url?

=========

Thanks,

 

William.

Posted
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!

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){

Posted

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...