Page 1 of 1

textarea data

Posted: Wed Jun 18, 2003 10:52 am
by cbcampbell
i am having trouble getting a textarea box in a form to output it's data to a mysql database. all my regular form INPUT boxes work just fine, but the data from the text area box doesn't go to the assigned field like with the other one line INPUT fields.

Here is an example of my one line INPUT box...

<input name="call_phone" type="text" size="13" maxlength="12">

and here is the TEXTAREA box...

<textarea name="call_mess"></textarea>

and here is the php/mysql that puts it into the database...

$query = "INSERT INTO callog VALUES ('',NOW(),'$call_to','$call_first','$call_last','$call_phone','$call_mess')";


all the other fields go into the databse correctly, except for the textarea. Is there something I'm missing?

Posted: Wed Jun 18, 2003 10:57 am
by Wayne
that should work, is there the correct number of values for the number of columns that you have in the table?

you might want to change the query to specify the columns you want to insert into.

Posted: Wed Jun 18, 2003 11:22 am
by cbcampbell
it worked....i don't know what i did differently. Oh, while I'm at it, is there anyway to format the output of the textarea so that say when i prematurely start a new line it will have the line breaks in the output:

***example input into the textarea box****

this is a wonderful
test message

**************

***the output i get from the textarea box****

this is a wonderful test message

**************

***the output i want from the textarea box*******

this is a wonderful
test message

**************

thank you all so much for your help...I just love forums!

Posted: Wed Jun 18, 2003 11:24 am
by patrikG
Have you tried changing the names?

So instead of

Code: Select all

<input name="call_phone" type="text" size="13" maxlength="12">

and here is the TEXTAREA box...

<textarea name="call_mess"></textarea>
try

Code: Select all

<input name="callphone" type="text" size="13" maxlength="12">

and here is the TEXTAREA box...

<textarea name="callmess"></textarea>

Posted: Wed Jun 18, 2003 11:36 am
by releasedj
Try:

Code: Select all

<textarea name="call_mess" wrap="physical"></textarea>

Posted: Wed Jun 18, 2003 11:48 am
by releasedj
Or maybe:

Code: Select all

<textarea name="call_mess" style="white-space: pre"></textarea>
As the wrap attribute is not standard compliant.

Posted: Wed Jun 18, 2003 12:02 pm
by cbcampbell
i tried the wrap....it formats it correctly in the actual database...but it doesn't when i output it to my php webpage....

Code: Select all

$query="SELECT * FROM callog ORDER BY call_date DESC";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center><font size='6'>The Call Log</font></center></b><br><br>";

$i=0;
while ($i < $num) &#123;

$call_to=mysql_result($result,$i,"call_to");
$call_date=mysql_result($result,$i,"call_date");
$call_first=mysql_result($result,$i,"call_first");
$call_last=mysql_result($result,$i,"call_last");
$call_phone=mysql_result($result,$i,"call_phone");
$call_mess=mysql_result($result,$i,"call_mess");

echo "<b>$call_last, $call_first</b><br><u>TO</u>: $call_to<br><u>Date</u>: $call_date<br><u>Phone</u>: $call_phone<br><u>Message</u>: $call_mess<br><hr><br>";
any other suggestions?

Posted: Wed Jun 18, 2003 12:05 pm
by releasedj
That's cause it's storing the newlines as \n's which are not displayed in HTML.

try doing:

Code: Select all

<?php
echo "<b>$call_last, $call_first</b><br><u>TO</u>: $call_to<br><u>Date</u>: $call_date<br><u>Phone</u>: $call_phone<br><u>Message</u>: ".nl2br($call_mess)."<br><hr><br>";
?>

Posted: Wed Jun 18, 2003 12:51 pm
by cbcampbell
it worked! thanks a million! :D