Zen Cart Logo
Forums / General Questions / Apostrophe, Single Quote, PHP, Text Entry

Apostrophe, Single Quote, PHP, Text Entry

Locked

Views: 7,317

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
24 Nov 2008, 3:42 PM
#1
brushwoodnursery avatar

brushwoodnursery

Zen Follower

Join Date:
Dec 2006
Posts:
199
Plugin Contributions:
0

Apostrophe, Single Quote, PHP, Text Entry

Can someone explain how text data is kept from messing up code when an apostrophe is entered? Examples would be possessives used in a business name or something in the Comments box at checkout.

24 Nov 2008, 4:18 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,603
Plugin Contributions:
0

Re: Apostrophe, Single Quote, PHP, Text Entry

From the FAQs for editing the "Welcome" message...

Edit the message starting from the word “Welcome” but be careful not to change the text in angled brackets, or the brackets themselves. Make sure that the single quote marks are not left out. If you want to include an apostrophe in your text e.g. “Lucy's Store”, you will need to put an escape character before the apostrophe, i.e. “Lucy's Store”.

24 Nov 2008, 4:23 PM
#3
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Apostrophe, Single Quote, PHP, Text Entry

As PHP uses single quotes within its scripting language you may need to escape any apostrophes used when editing PHP files.

The language files are good example.

includes/laguages/english/index.php

define('TEXT_BUY', 'Buy 1 '');
define('TEXT_NOW', '' now');

24 Nov 2008, 6:31 PM
#4
brushwoodnursery avatar

brushwoodnursery

Zen Follower

Join Date:
Dec 2006
Posts:
199
Plugin Contributions:
0

Re: Apostrophe, Single Quote, PHP, Text Entry

Well, I was talking about the customer entering data. I know about backslash.
I've found out that the text entered is protected by a function.

mysql_real_escape_string($zp_string);
24 Nov 2008, 9:11 PM
#5
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,603
Plugin Contributions:
0

Re: Apostrophe, Single Quote, PHP, Text Entry

Ah - sorry, we misunderstood the question. There are several built-in "cleaners" in Zen Cart.

24 Nov 2008, 10:42 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Apostrophe, Single Quote, PHP, Text Entry

Perhaps you would explain the reason behind your question?

You don't want to use mysql_real_escape_string directly.

25 Nov 2008, 2:57 PM
#7
brushwoodnursery avatar

brushwoodnursery

Zen Follower

Join Date:
Dec 2006
Posts:
199
Plugin Contributions:
0

Re: Apostrophe, Single Quote, PHP, Text Entry

The issue has been resolved. I had a programmer add an extra box at checkout for a gift message to be entered. It gets printed directly onto the packing slip so it's better for my purposes than having it in the comments box. This has been working well for me on my old platform (osC). However, it created errors when an apostrophe was entered on this new one (Happy Mother's Day, for example) and I wasn't sure if he didn't set it right or if my subsequent mucking around in the code had removed the proper protection. He has since fixed it.

He did this gift message box along with a dropdown selector at checkout that I've needed for my switch from osC to Zen. I've encouraged him to release it to the community since there are other who have wanted it. It generally goes against cart optimization to ask extra questions but the nature of my business requires it.

I'm really pleased working with Zen. It's been a joy compared to that clunky old platform.