Page 1 of 1
[SOLVED] Keeping a text areas formatting...
Posted: Thu Jun 24, 2004 4:53 pm
by jonas
Say I have a text area that users can type in and they want to format it with spaces and such.
Well when I insert it into the DB, it strips the spaces and the formatting.
I'm sure there is an easy fix for this, but I don't know what it is.
Any suggestions? Thanks.
Posted: Thu Jun 24, 2004 5:57 pm
by kettle_drum
Replace all /n with <br />'s and all spaces with or tabs.
Posted: Thu Jun 24, 2004 9:00 pm
by jonas
I don't follow entirely what you mean. Obviously check the text area for spaces and replace with but how?
Posted: Thu Jun 24, 2004 9:01 pm
by d3ad1ysp0rk
Code: Select all
$text = str_replace(" "," ",$_POST['text']);
Posted: Thu Jun 24, 2004 9:23 pm
by feyd
you'll have to quote lil's post to get the text.. the site decided to hide it..

Posted: Thu Jun 24, 2004 10:57 pm
by Leedsoft Solutions
Posted: Sat Jun 26, 2004 10:39 am
by jonas
It's not working for me ... I dont think.
I put it in my code but when I submit a text area, first off now if its too big it says server not found (like the page wont even load) and secondly if i do a smaller submission, the text area's variable in the DB is all empty.
It's almost as if it turns the entire string to spaces but that cannot be because if I try to submit the same thing again, my submission checker for the same code kicks in and gives an error.
Code: Select all
if ($Submit == "Submit Code"){
$code_text = strip_tags($code_text);
$sql_username_result = mysql_query("SELECT * from game_codes WHERE memberID='$memberID' AND code_title='$code_title'");
if (empty($code_title)){
$error = 1;
$nocodetitle = "You did not fill out a code title.";
}
if (empty($code_text)){
$error = 1;
$nocodetext = "You did not fill out a code description.";
} else {
$code_text = str_replace(" ","nbsp;",$code_text);
}
PS: The nbsp code on my actual server does have a & but i took it out here to show you.
Posted: Sat Jun 26, 2004 4:55 pm
by jonas
Solved, thanks for your help guys.