p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

php_databases thread: replacing ' with &rsquo&#59; before writing to database

Message #1 by "Kevin Price" <creature_of_the_id@y...> on Fri, 17 Jan 2003 15:26:27
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 &rsquo; 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...
>Should I just use a javascript replace function on the first page to 
>replace the character before it is sent. (this can cause problems as 
>javascript can be disabled).
>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

  Return to Index