Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Inserting text with apostrophes


calebic

Recommended Posts

Hi All,

 

I'm trying to learn more about programming in osC, and I'm wondering if anyone can explain how apostrophes are dealt with during database insertion/updating.

 

I am using the tep_db_prepare_input function before inserting/updating in the database, and then the tep_db_output function before displaying the value, however all my apostrophes come out with the "\" still in front of them.

 

Any thoughts or suggestions are greatly appreciated!

Link to comment
Share on other sites

The apostrophe is a control character in php. If you want to use it as something else, you have to proceed it with a \.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Yep ... that make sense to me. It is my understanding that you place the "\" before an "'" because in php "'" denotes a string variable.

 

So when I fill out my form, say I enter "why isn't this working" in the text area. Then when it is updated in the database, it is somehow being automatically changed to "why isn\'t this working". My assumption was that the tep_db_prepare_input function is doing this automatically, which is good!

 

But when I display the value of the field in the database, the text is displaying as "why isn\'t this working". Naturally I do not want my users/site visitors to see the "\", but rather see it the way it would be in normal writing(i.e. "why isn't this working").

 

So I was thinking that as long as I used the tep_db_output function to display the field value, it would not display the "\". However that doesn't seem to be the case, so I'm just trying to understand what I am missing.

 

Anyone know what steps need to be done to input and output text fields that may include apostrophes?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...