MySQL single and double quotes insertion

More than often while inserting some description into MySQL from a form input one faces a ‘single and double quote’ problem. For example while inserting the following text –

I have both ‘ and ” quotes in my description

To make the text safe for a MySQL insertion parse it with mysql_real_escape_string()

That would make it MySQL safe and would insert the correct text.

2 comments

  1. Isn’t it better to edit the trasalnte text as normally, even if Modules are not 100% trasalnted the developer use __( bla bla’) and all we need is to add the default text as a new line in the localized file and enter the localized text?I do this as I fell safer that reading from DB.I had problems that I localized using this feature and some strings were not localized arghhh Magento why r u so difficult!

Leave a comment

Your email address will not be published. Required fields are marked *