Forum Moderators: coopster

Message Too Old, No Replies

Need fast help! Apostrophe's

         

smiddy

10:15 pm on Mar 1, 2005 (gmt 0)

10+ Year Member



I have a php form that uses a textarea code to accept a description from users. Low and behold, it wasn't tested with an apostrophe in it. Naturally the apostrophe kills the insert.

Does anyone know how to get around this? The description field is pretty big and can be up to 100 words.

Need help asap.

Thanks!

Timotheos

10:35 pm on Mar 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Naturally the apostrophe kills the insert.

Which also means you're open to SQL injection attacks [webmasterworld.com]. What's needed here is the addslashes [php.net] function.

dreamcatcher

12:16 am on Mar 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also convert the apostrophes to character entities using str_replace or htmlentities

$text = str_replace("'", "'", $text);

dc