cemfundog Posted January 5, 2009 Share Posted January 5, 2009 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 More sharing options...
germ Posted January 5, 2009 Share Posted January 5, 2009 $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 More sharing options...
cemfundog Posted January 5, 2009 Author Share Posted January 5, 2009 $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 More sharing options...
♥FWR Media Posted January 5, 2009 Share Posted January 5, 2009 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"; } Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.