Log in

View Full Version : Resolved Getting rid of backslashes



Anne Arbor
01-23-2014, 01:48 AM
I have a very simple program that, in its output, inserts a backslash before every apostrophe and before every quotation mark (whether single or double). For example: He will call you after he/'s finished the laundry. He said, /"The minute I/'m finished./"

I've read about this and I know it has to do with 'escaping'. And I've read about Magic Quotes and/or stripslashes() but I've never entirely understood either of those and never managed to get rid of these ^&&()^%% backslashes.

The relevant line of code seems to be: echo $row['notes'];

I'm using PHP 5.3.27 .

Do I just add stripslashes() somehow?

echo stripslashes($row['notes']); -- would that work? I have no idea what the proper syntax would be.

Anne Arbor
01-23-2014, 03:17 AM
Hey, I edited my code, as described above, and it worked! Not only took the backslashes out of my new entry, but deleted them from every previous entry made during the past two years.

Okay, do I get to give myself "Thanks" for having solved the problem? Just wondering. :-)

james438
01-23-2014, 04:00 AM
You should have a file in your root directory or above called php.ini or php5.ini depending on your hosting configuration. When you open the file you will see some options for disabling the magic quotes. I changed mine to the following:

magic_quotes_runtime = off
magic_quotes_sybase = off
magic_quotes_gpc = off

If those lines are not present at all you can add them. See

http://www.php.net/manual/en/security.magicquotes.disabling.php

for more information.

Oddly enough we were able to give ourselves thanks in the previous version of vBulletin here on the forums :p. If you do come up witha cool trick or solve your own problem like above I would encourage you to leave your solution for others to find.