techxplore blog
19 Jun

Removing Additional Back Slashes Saved On Oracle Text Data Column

I was working with a project where PHP is used to accept entry for saving data to an Oracle Database. The saving of the entered data is working fine, but I was puzzled of the additional back slash before an apostrophe mark in the stored text data. I have not even used addslashes() to put some escape character like back slash. Everything is plain simple data entry form which uses post to submit the data to an action page for saving.

So, addition of back slashes was not done by the action page, but was something from the setup. I have checked on PHP information using phpinfo() and found that the PHP directive magic_quotes_gpc is on. By default magic_quotes_gpc is on and it acts like running addslashes() on all GET, POST, and COOKIE data passed. This is the one causing all the trouble.

Since, I don’t have access to the PHP.INI file. I was thinking at first of using stripslashes() to get rid of the slashes during saving. This means that I will add it on all $_POST[] of my action page. Too much work to do. So, I finally decided to convince my system administrator to have magic_quotes_gpc set off. The changes only took effect after the apache web server was restarted. That one solved my problem on the succeeding entries to the database; the back slashes together with the saved text data on Oracle database was gone auto magically. Though correcting the data stored earlier was to be updated manually to remove the back slashes.

Leave a Reply