PHP replacing ' and " with \' and \" ..can it be s

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

PHP replacing ' and " with \' and \" ..can it be s

Post by Gen-ik »

I've got a message forum on the site I'm making at the moment.

The user adds a message using a standard form.

The message gets saved to a .txt file.

Now, for some reason PHP keeps replacing ' and " symbols with '' and \" ..is there any way to stop this?

I'm using the standard PHP command to strip out any HTML code from the users message.

Any ideas?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

are you using addslashes?

try htmlentities()
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Thanks.. the stripslashes function worked. Don't know how I missed it in the first place! Oh well.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

You have the magic quote in PHP that's why it does that.
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post by gotDNS »

Code: Select all

$forminfo = stripslashes($forminfo);
then add $forminfo to the text file.
Post Reply