Those darn slashes

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ssand
Forum Commoner
Posts: 72
Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa

Those darn slashes

Post by ssand »

8O I am having trouble with \ (backslashes) entered from a form and inserted to mysql. It is just leaving them off. I am using addslashes() but for the backslashes it doesn't seem to work??

Any tips?

Thanks - Steve
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Magic Quotes

Post by josa »

Maybe the server you're using has magic quotes enabled for PHP. If this option is enabled PHP automatically adds slashes when form data is posted and if you use addslashes(), then another set of slashes is added. Echo out phpinfo() and look for magic_quotes_gpc under Configuration/PHP Core.

/josa
ssand
Forum Commoner
Posts: 72
Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa

Post by ssand »

Yes, magic_quotes_gpc is ON. Do I still stripslashes? or is the magic_quotes_gpc catch that also?

Thanks - Steve
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You still need to use stripslashes() to get rid of the added slashes because magic_quotes_gpc only affects data from a form and not stuff you've grabbed from the database.

Mac
ssand
Forum Commoner
Posts: 72
Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa

Post by ssand »

Thanks - I'll give it a try!
:D
Post Reply