textarea data

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
cbcampbell
Forum Newbie
Posts: 19
Joined: Mon Jun 09, 2003 12:12 am

textarea data

Post 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?
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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.
User avatar
cbcampbell
Forum Newbie
Posts: 19
Joined: Mon Jun 09, 2003 12:12 am

Post 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!
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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>
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post by releasedj »

Try:

Code: Select all

<textarea name="call_mess" wrap="physical"></textarea>
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post by releasedj »

Or maybe:

Code: Select all

<textarea name="call_mess" style="white-space: pre"></textarea>
As the wrap attribute is not standard compliant.
User avatar
cbcampbell
Forum Newbie
Posts: 19
Joined: Mon Jun 09, 2003 12:12 am

Post 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?
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post 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>";
?>
User avatar
cbcampbell
Forum Newbie
Posts: 19
Joined: Mon Jun 09, 2003 12:12 am

Post by cbcampbell »

it worked! thanks a million! :D
Post Reply