Saving HTML "textarea" to a MySQL database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Saving HTML "textarea" to a MySQL database

Post by Bigun »

I'm attempting to save a HTML textarea to a MySQL database.

It kinda works, except it doesn't seem to like newlines.

Like:

Code: Select all

foo

bar
Only Saves:

Code: Select all

foo
What gives?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What is the field type in your table?
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

varchar(255)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I'm not sure a varchar() field can handle text type stuff. Try changing the field type to text and see if that does anything different.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

varchar is a text type. It can handle it, the problem can easily be that the code you've entered is longer than 255 characters, the limit of your field.
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

Bingo... that did it.
Post Reply