nezbo Posted December 31, 2007 Share Posted December 31, 2007 Hi all i have created form that saves to a MySql database. i am using a TEXTAREA to capture some info, it is working fine but i have one problem. when i recall the info it comes back unformated, i.e. with no carage returns in it. i am not to sure out to over come this. has any one any idea ? Neil Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/ Share on other sites More sharing options...
jitesh Posted December 31, 2007 Share Posted December 31, 2007 http://www.phpfreaks.com/forums/index.php/topic,174937.msg774153.html Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426612 Share on other sites More sharing options...
nezbo Posted December 31, 2007 Author Share Posted December 31, 2007 Thank you for the quick responce, but i am a bit confused... ??? i have setup in the part where it displays the text, but it still dose not put it on new lines. do i also need to do some thing with the $_post bit to make sure that it puts a <br /> or a /n in the line of text. the text area seems to be missing the code to the nl2br() to work. echo "<td align=left>"; echo nl2br($row['OutCome']) . "<br />"; echo "</td></tr>"; <TEXTAREA NAME=OutCome ROWS=15 COLS=80></TEXTAREA> Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426626 Share on other sites More sharing options...
nezbo Posted December 31, 2007 Author Share Posted December 31, 2007 if i do a text text like this <br /> is <br /> a test it displays as i want it to. but how do i get it to automatickly put the <br /> in the text when i press enter ? Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426628 Share on other sites More sharing options...
jitesh Posted December 31, 2007 Share Posted December 31, 2007 When you are saving data into db you need to use this function. INSERT INTO `table` (`id`,`info`) VALUES (1, nl2br(' ...... ')); nl2br is a PHP function. Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426630 Share on other sites More sharing options...
nezbo Posted December 31, 2007 Author Share Posted December 31, 2007 cool cheers i have now got the code and it is now not puting anythin in to the database ??? here is my code $sql = "INSERT INTO outcomes( outcomeID, jobID, theOutCome, outcomeDate, outcomeTime, userID ) VALUES ( '', '$jobCallID', nl2br('$outcomeString'), '$callDate', '$callTime', '$UsID' )"; i also get this error Error : FUNCTION call_log.nl2br does not exist When you are saving data into db you need to use this function. INSERT INTO `table` (`id`,`info`) VALUES (1, nl2br(' ...... ')); nl2br is a PHP function. Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426634 Share on other sites More sharing options...
nezbo Posted December 31, 2007 Author Share Posted December 31, 2007 i have also tryed this, and i get nothing in the outcome... $outcomeString2 = nl2br($outcomeString); $outcomeString = $_POST['OutCome']; $sql = "INSERT INTO outcomes( outcomeID, jobID, theOutCome, outcomeDate, outcomeTime, userID ) VALUES ( '', '$jobCallID', '$outcomeString2', '$callDate', '$callTime', '$UsID' )"; Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426641 Share on other sites More sharing options...
nezbo Posted December 31, 2007 Author Share Posted December 31, 2007 Sorry i was being silly i put the comversion over the $_post bit all sorted now. cheers for all your help neil Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426643 Share on other sites More sharing options...
jitesh Posted December 31, 2007 Share Posted December 31, 2007 <?php $sql = "INSERT INTO outcomes( outcomeID, jobID, theOutCome, outcomeDate, outcomeTime, userID ) VALUES ( '','".$jobCallID."','".nl2br($outcomeString)."','".$callDate."','".$callTime."','.".$UsID."')"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426646 Share on other sites More sharing options...
GingerRobot Posted December 31, 2007 Share Posted December 31, 2007 I think most would agree that it's more conventional to apply the nl2br function when you retrieve the data from the database, not when you enter it into the database. The function converts new lines to the HTML break line tag, which would only be wanted when the data is output as HTML. So if you wanted to output the data in some other way (like in a text file), then the break lines would be unwanted. Quote Link to comment https://forums.phpfreaks.com/topic/83828-solved-textarea-in-php-and-mysql/#findComment-426653 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.