Warptweet Posted March 24, 2007 Share Posted March 24, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/ Share on other sites More sharing options...
AndyB Posted March 24, 2007 Share Posted March 24, 2007 use the nl2br() function on the output text to convert 'newlines' to html br tags Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214452 Share on other sites More sharing options...
suzzane2020 Posted March 24, 2007 Share Posted March 24, 2007 Wow..So there are functions for these . Cud u give me a link for such functions? Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214454 Share on other sites More sharing options...
Warptweet Posted March 24, 2007 Author Share Posted March 24, 2007 Thanks! I'll look at php.net about nl2br() Sorry, I would have expected something called nl2br() to have anything to do with it.. PHP.net is confusing Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214455 Share on other sites More sharing options...
AndyB Posted March 24, 2007 Share Posted March 24, 2007 Wow..So there are functions for these . Cud u give me a link for such functions? www.php.net and use the search box for any function you want. Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214476 Share on other sites More sharing options...
Warptweet Posted March 24, 2007 Author Share Posted March 24, 2007 Sorry, I put it on the output text, but it doesn't work. When it submits the info into my DATABASE, how can I translate the enter spaces into </br>? Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214478 Share on other sites More sharing options...
AndyB Posted March 24, 2007 Share Posted March 24, 2007 Can we see how you're using it (in the case where it doesn't work)? Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214493 Share on other sites More sharing options...
wildteen88 Posted March 24, 2007 Share Posted March 24, 2007 You use nl2br as AndyB advised. How are using that function. Post the code you use to output the data from the database. Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214500 Share on other sites More sharing options...
desithugg Posted March 24, 2007 Share Posted March 24, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/44165-text-area-spacing/#findComment-214514 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.