apostrophe(')

They have: 164 posts

Joined: Nov 2001

i have a text field where user can key in some coments...

when user have key in something with an apostrophe(') in it, it generate sql error.....

how can i solved it?

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

text wrangle -- when the form is submitted, replace all ' with \' or with &rsquot; or whatever html entity you want to use.

THEN save it to the database.

They have: 601 posts

Joined: Nov 2001

Use the built-in MySQL Quote function to overcome this. In Perl, this would be something like:

$field = $dbh->quote($field);
'

They have: 11 posts

Joined: Mar 2002

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.