Jump to content

Text Area spacing...?


Warptweet

Recommended Posts

I have a form, and it's a text area. If I press enter twice, it makes a double space, but when I press submit, and it changes the page, it does not double space!. How can I make my code translate those "enter button" presses into a new line?

 

Just in case you need to know, it's writing whats inside the text box into a row in my MySQL Database. So in a way, you could say that when you press the "enter" button, the text area does not take it as a new line. Here is my code to do so...

 

if ($_GET['cmd'] == 'useredit'){
if ($_GET['edit'] == 'profile'){

$users_names = $_SESSION['s_username'];

$con = mysql_connect("localhost","warp_gm","Forest77");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("warp_gm", $con);

$result = mysql_query("SELECT * FROM gm_users
WHERE username='$users_names'");

while($row = mysql_fetch_array($result))
  {
echo "<form method=\"POST\" action=\"?cmd=useredit&edit=textedit\">
<p align=\"center\">
  <textarea rows=\"8\" name=\"profile_text\" cols=\"46\">" . $row['profile_text'] . "</textarea><input type=\"submit\" value=\"Submit\" name=\"B1\"></p>
</form>";
}
}
}

 

It works, no error is returned, it's simply that it doesnt make a new line.

Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/44165-text-area-spacing/
Share on other sites

umm I had that problem too before

I tried to use nl2br before recording it in the database but it didn't work

so than I used nl2br right before echoing it

so

$text = "adsasdaskmask
adsads
asda
sd";
echo nl2br($text);

well you can try that it did work for me

Link to comment
https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214514
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.