Dealing with apostrophes in form input - output

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
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

Dealing with apostrophes in form input - output

Post by michlcamp »

I have a form that members to my site fill out with bio information, then the form data is posted to a database table.


They often include apostrophes in the text, which when output to a database-generated page display backslashes in front of the apostrophe.

ex: "Welcome to Mike\\\'s page..."

I know this is a fairly common problem but am wondering what code to include that will:

1) keep the slashes from being added in when the form data is input to the table,

and

2) keep them from displaying in the output.

I'm already using "str_replace(Chr(13)," code to display the line breaks from the textarea field...

Code: Select all

$bio=mysql_result($result,$i,"bio");
$bio2=str_replace(Chr(13), "<br>", $bio);
wondering how to handle the apostrophes...

any help appreciated in advance..
thanks.
mc
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply