Jump to content

[SOLVED] TEXTAREA in php and mySQL


nezbo

Recommended Posts

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

Link to comment
Share on other sites

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>

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'
					)";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.