Posting Data To the Database
Posted: Tue Feb 13, 2007 6:30 am
Gaah! I'm ripping my hair out on this one. Here's my problem. I want to post text field data from these HTML TEXTAREA tags to a PostgreSQL database and have it reappear back on another page exactly as I had typed it. Over the years I have done this but only did it with simple text. This time around, I want to handle much more complex text. I need to preserve some kinds of features.
(Yes, I have turned off magic quotes.)
- Need to strip diacritics. I learned I could use htmlentities to catch &?grave;, &?acute;, &?circ; &?uml; &?tilde; &?cedil; and the ? can become the character I wish to preserve and strip the others.
- Need all text to be saved in US-ASCII format.
- Need to save all \r and \n as literally that in the database so that SQL selects show everything on one line. This makes it easier to deal with the records with the psql command.
- Need to preserve all US-ASCII characters so that things, such as ', ", \, <, >, %, &, and --, are preserved. I want the database to be able to store these items and not munge them on me reading them back out.
Basically I have a $web object with a Request('fieldname') method and I need this function to handle the above for me.
Any advice would be greatly appreciated.
(Yes, I have turned off magic quotes.)
- Need to strip diacritics. I learned I could use htmlentities to catch &?grave;, &?acute;, &?circ; &?uml; &?tilde; &?cedil; and the ? can become the character I wish to preserve and strip the others.
- Need all text to be saved in US-ASCII format.
- Need to save all \r and \n as literally that in the database so that SQL selects show everything on one line. This makes it easier to deal with the records with the psql command.
- Need to preserve all US-ASCII characters so that things, such as ', ", \, <, >, %, &, and --, are preserved. I want the database to be able to store these items and not munge them on me reading them back out.
Basically I have a $web object with a Request('fieldname') method and I need this function to handle the above for me.
Any advice would be greatly appreciated.