It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Commas and quotes changing to \\\"

Moderator: Malcolm

Commas and quotes changing to \\\"

Postby PsxMeUP on Sat Sep 26, 2009 12:59 pm

Hi, I have a site where commas and quotes change to \" once the article is posted (but only when it's written directly in the site's interface).

Some have proposed that it's because magic_quotes are set to on (and they are because I checked using <?php phpinfo(); ?>). I checked my php.ini file and it doesn't have that code, meaning it's probably set up on my hosting provider's side. So what are my options? Should I turn them off somehow (I read it might damage some of my code if I do)? Isn't it better to have them on? Is there something I can do to fix this problem? The site lets users post game reviews, and the last thing I want is a note saying "Warning, you must type your text in Word first," cause it would look lame, and I definitely want the site to be perfectly optimized.
PsxMeUP
 
Posts: 1
Joined: Sat Sep 26, 2009 12:56 pm

Re: Commas and quotes changing to \\\"

Postby dflynn on Tue Dec 29, 2009 5:21 am

If you are saving the text to a database you have escape your characters on the way in and strip them on the way out.
This is so that users can't write destructive scripts into your database.

using mysql_real_escape_string(); on the way in and stripslashes(); on the way out should take care of the problem.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada


Who is online

Users browsing this forum: No registered users and 0 guests