[SOLVED] textarea into mysql

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
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

[SOLVED] textarea into mysql

Post by ecaandrew »

Hello everyone, im trying to figure out how to get this to work, i want it so when the user hits enter or whatever "carriage return", i want it inserted in the database like that, so when i call it from the database, it will display it exactly how the user typed it.

Code: Select all

<textarea name=&quote;message&quote; cols=&quote;50&quote; rows=&quote;8&quote;>


----------------- Original Message -----------------
From: <?php echo &quote;&quote;.$row_inbox&#1111;'from'].&quote;&quote;; ?>

Date: <?php echo &quote;&quote;.$row_inbox&#1111;'date'].&quote;&quote;; ?>


<?php echo &quote;&quote;.$row_inbox&#1111;'message'].&quote;&quote;; ?>
</textarea>

thanks!
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

as long as you define the mysql field as TEXT it should retain everything that the user typed in and how it was typed.
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post by ecaandrew »

i dont think its doing it, i have it on TEXT
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

is there any way i can see it in action?

edit: try adding wrap="virtual" in your textarea...

<textarea wrap="virtual" name="message" cols="50" rows="8">

cuz i konw it works for me 8O
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post by ecaandrew »

i tryed it no luck

http://xeofriends.com/


register, its a script im writing, login and go to "view my profile" and send yourself a message, and than reply to your own message, youll see it in action
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

OK. I tested it out and created my profile (n00b Saibot , of course ;) ). Good Site but the matter layout in center is cropped about 10 px on right.
While Testing the Replies thingy, i saw what you were trying to say.
the text in textarea shows right. i think you want it to show the line breaks when you display the message. Right ?
well you have to run the mesage thru nl2br(). that will solve your prob.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

oh.. that's cuz you are just spitting that data out on the screen.. not back into a textarea (completely misunderstood ya...)

you should check out this post then.

http://www.devnetwork.net/forums/viewtopic.php?t=17053



edit: the topic i just posted pretty much says what n00b suggested anyways, although it makes some pretty good points about using nl2br
Last edited by infolock on Thu Mar 17, 2005 4:01 am, edited 1 time in total.
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

I think wrap="hard" will do.
ecaandrew
Forum Commoner
Posts: 72
Joined: Fri Nov 12, 2004 5:05 pm

Post by ecaandrew »

n12br() worked awesome, thankyou :)

Code: Select all

<?php 
	$mes = nl2br($row_inbox&#1111;'message']);
	echo $mes;
	?>
is what i did
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url]
Post Reply