Headhunter
|
| Posted: 04/14/2002, 12:24 AM |
|
Question,
when I insert text to a MySQL database (via PHP4), the text submitted in the text area is formatted (line brakes). When viewing the result in a label field, I want the text also displayed as it was typed in (line brakes is the only thing I need). Do I need to use "addslashes" or something and how do I implement it?
Check it out on http://headhunter.dnsalias.org:14030/trackit?mode=index
login: guest
pasword: guest
Note: it's in dutch...
Just follow "pc lijst" -> click on any serienr. -> click the "service beheren" link, just look at the "notities field" and look what I mean.
Don't do anything I wouldn't do. (don't worry, it's a test database.)
|
|
|
 |
feha
|
| Posted: 04/14/2002, 2:06 AM |
|
I'm working on that soulution too..
So far the problem I have solved in PERL/CGI look's like:
#This subroutine you call before you show the text on HTML...
$text_from_db="Your text seleceted from DB";
sub text_format
{
$my_format=$form_data{$text_from_db};
$my_format=~ s/</</g;
$my_format=~ s/>/>/g;
$my_format=~ s/\cM//g;
$my_format=~ s/\n\n/<p>/g;
$my_format=~ s/\n/<br>/g;
$my_format=~ s/( |\t)+/ /g;
$my_format=~ s/\n+/<br>/g;
$my_format=~ s/^\s*//;
$my_format=~ s/\s*$//;
$form_data{$text_from_db}=$my_format;
}
###############################################################
$text_format="your text...";
#This sub you call before you insert in to DB...
sub my_format_in
{
$text_format=~ s/<p>/\n\n/g;
$text_format=~ s/<br>/\n/g;
}
I'm working on PHP version...
feha
[url]www.vision.to[/url]
|
|
|
 |
|