curi0us Posted June 5, 2009 Posted June 5, 2009 Hello, I made my oscommerce to add an image in description. Image based on product model <center> <img src="img/<?php echo $product_info['products_model']; ?>.jpg" alt="<?php echo $product_info['products_name']; ?>" border="1"> </center> it works. Some times I have two versions of the same product. I want oscommerce to add second image when I use "Second version" in description. <?php $mystring = $product_info['products_description']; $findme = 'Second'; $pos = strpos($mystring, $findme); if ($pos === false) { echo "There is only one version of this product"; } else { echo "Here you can see second version of this product'"; <center> <img src="img/<?php echo $product_info['products_model']; ?>B.jpg" alt="<?php echo $product_info['products_name']; ?>" border="1"> </center> } ?> It should add second image (name based on products model +B letter). Code is correct but I get error anyone happens to know how it should look like? It's almost done, I just need to put it in else command properly. I would be grateful for help! Html tags in } else { are they key. When I put normal text it works.
curi0us Posted June 5, 2009 Author Posted June 5, 2009 Parse error: syntax error, unexpected '<' in /home/mw-soft/ftp/mwsoft/katalog/product_info.php on line 145 <center> is in line 145 It's becuase of html tags for sure. It needs to be put properly. When I tested it with code } else { echo "The string '$findme' was found in the string '$mystring'"; echo " and exists at position $pos"; } ?> it worked with } else { echo "Here you can see second version of this product'"; <center> <img src="img/<?php echo $product_info['products_model']; ?>B.jpg" alt="<?php echo $product_info['products_name']; ?>" border="1"> </center> } ?> It does not.
Nullachtfuffzehn Posted June 5, 2009 Posted June 5, 2009 you should close the PHP part before trying to output the HTML... } else { echo "Here you can see second version of this product'"; ?> <center> <img src="img/<?php echo $product_info['products_model']; ?>B.jpg" alt="<?php echo $product_info['products_name']; ?>" border="1"> </center> <?php } ?> should work.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.