Page 1 of 1

[SOLVED] textarea into mysql

Posted: Thu Mar 17, 2005 2:34 am
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!

Posted: Thu Mar 17, 2005 2:54 am
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.

Posted: Thu Mar 17, 2005 3:01 am
by ecaandrew
i dont think its doing it, i have it on TEXT

Posted: Thu Mar 17, 2005 3:06 am
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

Posted: Thu Mar 17, 2005 3:31 am
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

Posted: Thu Mar 17, 2005 3:51 am
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.

Posted: Thu Mar 17, 2005 3:56 am
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

Posted: Thu Mar 17, 2005 4:00 am
by AGISB
I think wrap="hard" will do.

Posted: Thu Mar 17, 2005 4:06 am
by ecaandrew
n12br() worked awesome, thankyou :)

Code: Select all

<?php 
	$mes = nl2br($row_inbox&#1111;'message']);
	echo $mes;
	?>
is what i did

Posted: Thu Mar 17, 2005 1:32 pm
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]