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.
Posting Data To the Database
Moderator: General Moderators
-
supermike
- Forum Contributor
- Posts: 193
- Joined: Tue Feb 28, 2006 8:30 pm
- Location: Somewhere in the Desert, USA
Posting Data To the Database
Last edited by supermike on Tue Feb 13, 2007 6:39 am, edited 1 time in total.
-
crazytopu
- Forum Contributor
- Posts: 259
- Joined: Fri Nov 07, 2003 12:43 pm
- Location: London, UK
- Contact:
I had a similar problem, but rather than using normal text area I had used tinymce http://tinymce.moxiecode.com/guestbook/ ... hp?page=35
It's a rich text editor, quite light and pretty cool if you want to see the content as it is saved in the database (with all the tags and stuff).
It's a rich text editor, quite light and pretty cool if you want to see the content as it is saved in the database (with all the tags and stuff).
-
crazytopu
- Forum Contributor
- Posts: 259
- Joined: Fri Nov 07, 2003 12:43 pm
- Location: London, UK
- Contact:
It's not complex at all. When one of my clients demanded to see the exact same copy of the site contents in a text area so they can change font, color etc etc, I was lost.
Then someone here pointed me to this nice tool. I had no idea how it works (its all done in JS) but i had used it just like you use a text area. Like, give a name to it, then grab the content by using GET, POST etc.
Easy, huh?
Then someone here pointed me to this nice tool. I had no idea how it works (its all done in JS) but i had used it just like you use a text area. Like, give a name to it, then grab the content by using GET, POST etc.
Easy, huh?
-
supermike
- Forum Contributor
- Posts: 193
- Joined: Tue Feb 28, 2006 8:30 pm
- Location: Somewhere in the Desert, USA
Okay, and so you just pull from it with $_POST['fieldname'] and write it, verbatim, straight into PostgreSQL and display it right back into the control by pulling from PostgreSQL, doing absolutely nothing to the field data as you get it, and write it exactly back into the control on the web page? It's that easy? No extra code you have to write?crazytopu wrote:It's not complex at all. When one of my clients demanded to see the exact same copy of the site contents in a text area so they can change font, color etc etc, I was lost.
Then someone here pointed me to this nice tool. I had no idea how it works (its all done in JS) but i had used it just like you use a text area. Like, give a name to it, then grab the content by using GET, POST etc.
Easy, huh?
And do you have your magic quotes turned off in your project?
Are you using PostgreSQL as your backend or something like SQLite or MySQL instead? Perhaps with PostgreSQL you have to do something different?
-
crazytopu
- Forum Contributor
- Posts: 259
- Joined: Fri Nov 07, 2003 12:43 pm
- Location: London, UK
- Contact:
Yes, no extra code was required, atleast i didnot. Erm...dont remember about magic_quotes I think it was turned off. I used mysql, well you can try with PostgresSQL and let us know if it was that easy. I have the feeling, it would be a piece of cake even with PostgresSQL.Okay, and so you just pull from it with $_POST['fieldname'] and write it, verbatim, straight into PostgreSQL and display it right back into the control by pulling from PostgreSQL, doing absolutely nothing to the field data as you get it, and write it exactly back into the control on the web page? It's that easy? No extra code you have to write?
And do you have your magic quotes turned off in your project?
Are you using PostgreSQL as your backend or something like SQLite or MySQL instead? Perhaps with PostgreSQL you have to do something different?