Allowing ' through databases

Ask about a PHP problem here.
Post Reply
Carbine
Posts: 58
Joined: Fri May 06, 2011 1:47 pm
Location: UK, Nottinghamshire
Contact:

Allowing ' through databases

Post by Carbine »

I want ' and " to be allowed through the database, but without mysql injection. I use htmlentities, but that doesn't do anything to them. Sorry if this is a stupid question, I just don't want to injected :L I tried entering apos; in the articles to see if that's allowed through and if so I could just replace ' with apos; before it goes through, but using apos; and It still didn't work :L Thanks and sorry for all the questions.

/E should this be in the php security section?
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: Allowing ' through databases

Post by Tino »

You'll want to pass it the ENT_QUOTES flag.

[syntax=php]$var = htmlentities($_POST['var'], ENT_QUOTES);[/syntax]

This will convert both single and double quotes.
Please check out my CodeCanyon items.
Carbine
Posts: 58
Joined: Fri May 06, 2011 1:47 pm
Location: UK, Nottinghamshire
Contact:

Re: Allowing ' through databases

Post by Carbine »

Thanks very much Tino, you're a legend.
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: Allowing ' through databases

Post by Tino »

You're welcome. And thanks, I suppose :)
Please check out my CodeCanyon items.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Allowing ' through databases

Post by jacek »

There shouldn't be any problems if you escape them correctly :?
Image
Post Reply