Link to home
Start Free TrialLog in
Avatar of mkido
mkido

asked on

Single Quote Escape (\') Insertion Problem while writing and reading back a text file. How to handle?

Hello!    Everyone, I have a problem of BACK SLASH  INSERTION.

I am developing a Blog or Comment submission interface through Web_PHP.   Since I am dealing not only English but also other languages, I use UTF-8 as default charcter set at Apache.     I used a simple functions to write and read the UTF-8 text files.  

   fwrite();    and    readfile($filename);

Here comes a problem.   All single quotes are modified to have back slash (\), and each time read and write that text, back slash are increasingly inserted.   See example below.    

   Qu\'est ce que s\'est passé.
   Alors les résultats de recherche n\'ont plus le lien d\'agrafes de multimédia.

How to stop inserting those extra slashes?   Suggestion please!!    Help!
SOLUTION
Avatar of Raynard7
Raynard7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mkido
mkido

ASKER

Hello everyone, thank you very much.  

I will soon try to see what will happen by turning off,

   magic_quotes_gpc in php.ini

then, get back here.     Then, I will try,

   stripslashes().

Thanks.
Avatar of mkido

ASKER

Dear wasifq,

tunring off
  magic_quotes_gpc    in php.ini
worked.     wonderful!
I saw that when fwrite() wrote down the french text, it aldreay inserted the slash (\) in front of quote (').   Thus, I think it is better to prevent the insertion while PHP writes text down.    

Regarding stripslashes(), let me try a little later.   Thanks.
Avatar of mkido

ASKER

Thank you,
  Raynard7,  NewJorg,  and wasifq:

stripslashes() works well too.   I prefer to turn off "magic_quotes_gpc" in "php.ini" file.    Thanks for your help!