New Zenner
- Join Date:
- Jul 2006
- Posts:
- 71
- Plugin Contributions:
- 0
Post #1 by hdg
I'm using the latest version.
It seems that if the product name has a single quote in it, the image will not display. Is this normal? How can I fix this?
Started by hdg on 6 Jun 2007, 1:57 PM · Views: 5,370
New Zenner
I'm using the latest version.
It seems that if the product name has a single quote in it, the image will not display. Is this normal? How can I fix this?
Totally Zenned
Try putting a escape backslash \ in front of each single quote. PHP is getting confused with the single quotes and so for your text they need to handled with some extra care.
more info :: PHP Manual - Strings
edit:
FAQ :: reference
New Zenner
Okay, I tried that and got this error:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Poem Und. Plexi Glass', products_description = '12" X 15" Simulated Walnut Pla' at line 1
in:
[update zen_products_description set products_name = '12" X 15" Sim. Wal. Plq. Chief\''s Poem Und. Plexi Glass', products_description = '12" X 15" Simulated Walnut Plaque, Chief''s Poem Under Plexi Glass With 5 Trumpet Hat Badge.', products_url = '' where products_id = '3739' and language_id = '1']
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
I had changed 12" X 15" Sim. Wal. Plq. Chief's Poem Und. Plexi Glass to 12" X 15" Sim. Wal. Plq. Chief's Poem Und. Plexi Glass
Totally Zenned
Sorry, my initial reply pertained more toward language defines and such. How are you entering this product's data? Is it via the ZC Categories/Products admin, or are you trying to import data with an add-on or other non-Zen-Cart tool?
afaik, ZC properly sanitizes the inputed data upon submission to avoid such issues. I've checked with a clean installation of ZC 1.3.7, and using single or double quotes randomly within the Product Name and/or Product Description does not demonstrate the issue you are experiencing.
New Zenner
Here is the product that has the issue:
http://aaau.com/cart/index.php?main_page=product_info&cPath=838_841&products_id=3739
I am entering it normally, via the admin section.
If I simply delete the quote, the page is fixed and the image shows up.
Sensei
If you disable javascript in your browser, does it work properly ?
What addons and customizations have been done to your shop?
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
Yes, it works fine if Javascript is disabled.
I should mention most other product images work fine.
I believe the only changes have been changes to the template.
Sensei
Please post the contents of your /includes/templates/YOURTEMPLATE/templates/tpl_modules_main_product_image.php file.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
<?php
/**
* Module Template
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_main_product_image.php 3208 2006-03-19 16:48:57Z birdbrain $
*/
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?>
<div id="productMainImage" class="centeredContent back">
<script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id$
//--></script>
<noscript>
<?php
echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($product$
?>
</noscript>
</div>
Sensei
It appears that your file is corrupt.
Please re-upload that file from your original Zen Cart zip.
Be sure to replace the template_default one with the one from the zip, and if you have the same file in various template override folders, be sure to either replace them with the master or merge your customizations with the master before uploading and replacing the one in your overrides folders.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
Okay I have replaced tpl_modules_main_product_image.php with the original from Zen-Cart. But it did not fix it.
In fact, how is it corrupt? The Zen-Cart file (unchanged) is the same as what I posted.
Sensei
HDG:
In fact, how is it corrupt? The Zen-Cart file (unchanged) is the same as what I posted.
If you look at what you posted, and scroll to the right of the content, you'll notice that the lines are not complete.
HDG:
Okay I have replaced tpl_modules_main_product_image.php with the original from Zen-Cart. But it did not fix it.Line 15 of the file should read line this:
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');with line-breaks added for purposes of explanation, that becomes this:```
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, [B]addslashes($products_name)[/B], MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
The code you posted doesn't contain that.
A fresh install of Zen Cart doesn't exhibit the symptoms you describe.
So, the problem could be:
a. bad upload of files or otherwise corrupt files
b. mismatched code between template_default and a custom override file
c. a server configuration problem which causes the addslashes() function to not work correctly
I rather doubt that addslashes() is working incorrectly or else you'd be getting all kinds of database errors when trying to enter product information.
What is your PHP setting for magic_quotes ? (go to Admin->tools->server Info )
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
Oops, sorry! The lines are complete, I just didn't paste them correctly. PuTTy cut them off.
So my mistake. The file matches exactly to the stock ZenCart one. What now?
This is the full file:
<?php
/**
* Module Template
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_modules_main_product_image.php 3208 2006-03-19 16:48:57Z birdbrain $
*/
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?>
<div id="productMainImage" class="centeredContent back">
<script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
//--></script>
<noscript>
<?php
echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>';
?>
</noscript>
</div>
Sensei
What now?
I don't know.
I can't reproduce the problem on a clean install.
So, you'll need to compare your site to a clean site, and find out what differences or customizations are causing the problem:
http://www.zen-cart.com/wiki/index.php/Troubleshoot_-_Diagnosing_Obscure_Issues
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
Okay I've compared the entire site. The following folders exactly match to clean ZenCart:
admin
cache
download
email
pub
A lot of the files in includes are different, because the template was changed. Anything specific I should check out? I'm still looking over all the files and comparing.
New Zenner
I can't edit my post, don't know why. The edit button is gone. Anyway.
Here is what the item name looks like in the DB:
'12\" X 15\" Sim. Wal. Plq. Chief\'s Poem Und. Plexi Glass'
Sensei
Excellent. That's what it should be set to in the database.
Then, when Zen Cart loads it from the database, the quotes are converted to actual quotes instead of the " and ' representations.
Then, when the template goes to output to the browser, it normally just sends the content directly to the screen. However, in the case of the clickable link to popup, the product name is included as part of the image description, and since the javascript used to prepare the popup link has to use quote marks in its programming code, all the quotes in your product name need to be converted. That's what the addslashes() function in the template does.
Why it's not doing it on your site is a mystery.
I just set up a product using the same name as you've describe, and it works fine using a fresh clean install of v1.3.7
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
I'm not sure where to go from here. I don't want to replace files with stock ZenCart files because this site is live.
Is there a way to debug that addslashes line in that php file?
Sensei
It seems to be server-specific.
What version of PHP and MySQL are you running on your server?
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
New Zenner
Not sure if you noticed, but I did reproduce this on a stock ZenCart install:
http://www.zen-cart.com/forum/showthread.php?goto=newpost&t=68050
The server PHP version is 4.4.4 and MySQL 4.1.22-standard.
Tell staff why this post should be reviewed.