php_databases thread: replacing ' with &rsquo; before writing to database
There are one or two PHP function that clean up input.
htmlspecialcharacters() is one. You could also look at the code in
phpMyAdmin. I've seen it clean up punctuation marks.
Kevin Price wrote:
>I'm almost finished my project, but I have come across a problem.
>two fields that a user can input into are text fields. The user inputs
>descriptions of items.
>But, I have found that if the field contains the character ' then I get an
>error and no information is sent to the database.
>What I am wanting to do is replace that character, every time it appears
>within text with the html code for the character which is ’ or
>The input page posts all of the fields in the form to the next page and
>inputs the data into the database. it then displays the record in the way
>that it will appear when it is selected from the database.
>anyway... my problem is this...
>replace the character before it is sent. (this can cause problems as
>Or is there a way to do this to a variable with PHP on the page that it is
>sent to, before it is inserted into the database?
>Hope I was clear :)
>thanks in advance for any help you can give