Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

what is wrong with this code...


cemfundog

Recommended Posts

I am getting the following error:

 

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in

 

Her is the code I am trying to use, written by Jack_mcs:

 

$img = (isset($cPath && $cPath == 3) ? 'some_image.jpg' : '';

 

Where 3 is the id of the category you want to check.

 

Then, to show the image

 

<img src="<?php echo $img; ?>" alt="some text">

 

I believe this will work but something is wrong with the syntax i can not figure it out. I am truly 'green' here. Please help. I am trying to get an image to appear on my product info page but only when the user is in a specific category. Thank you so much for looking

Link to comment
Share on other sites

$img = (isset($cPath) && ($cPath == 3)) ? 'some_image.jpg' : '';

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

$img = (isset($cPath) && ($cPath == 3)) ? 'some_image.jpg' : '';

 

Thank you so much Jim. That fixed the parse error. But for some reason I still get no image in the spot I called it. That part is working but it only showes an empty box where the image should be. Any Idea what is wrong here? I figure I must be checking the wrong category ID. What is the best way to check the category ID? Thank you again for looking everyone.

Link to comment
Share on other sites

The code below should give you a structure to show images based on cPath.

 

// The numbers represent the cPath
$images = array('1'	  => 'some_image1.jpg',
			'2'	  => 'some_image2.jpg',
			'3'	  => 'some_image3.jpg',
			'4'	  => 'some_image4.jpg',
			'5'	  => 'some_image5.jpg',
			'3_5_32' => 'some_image_3_5_32.jpg');
if( isset($cPath) && isset($images[$cPath]) ){
 echo tep_image(DIR_WS_IMAGES . $images[$cPath], $alt = '', $width = '', $height = '', $parameters = '') . "\n";
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...