Ok I have a SQL db it saves user input from a <textarea> input box. Everything was working fine, then today, and believe me no code regarding diplaying and saving has changed, every 2 CRLF displayed with 4 CRLF and then when saved and screen displayed there were 6 CRLF, and so on each time the form was submitted and re-displayed 2 extra CRLF were appearing between each line of text.
and here is the display
I've left all the code in from the top down to the textarea in question just so you can see there is nothing being done to the data $hlp[0]{'PageText'}.
now before the display i've added this line
which rectifies the problem but why do i now need to do it?
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
becameLooking for a mortgage but don't know where to turn?
Need extra cash for that special purchase?
next time roundLooking for a mortgage but don't know where to turn?
Need extra cash for that special purchase?
you get the picture but WHY?, why did it save and retrieve fine before and not now and nothing has changed (I know you don't believe me guys - but here is the save routine and after checking the SQL there we only 2 CRLF as expected.Looking for a mortgage but don't know where to turn?
Need extra cash for that special purchase?
Code:
sub page_upd {
#_[0] = PageID
# Build Style String
my $tit = "$data{'TFont'},$data{'TFSize'},$data{'TitCol'},$data{'TBGCol'}";
my $txt = "$data{'PFType'},$data{'PFSize'},$data{'PTxtCol'},$data{'TxtBGColSel'}";
my $upd = "";
# Swap DSN to AR
&swap_dsn("AR");
# Check if page text has changed for user editible text.
if($_[0] eq "index" || $_[0] eq "aboutus"){
# Escape data
my @oldtxt = &getSQL("AR_Pages","PageText","ARID='$AR' AND PageID ='$_[0]'");
if($oldtxt[0]{'PageText'} ne $data{'PageText'}){
$upd = "y";
}
else {$upd = "n";}
}
# Escape Apostophe
$data{'PageText'} =~ s/'/''/g;
# Update Page Info
my $rs = &updSQL("AR_Pages","PageTitleStyle='$tit',PageTextStyle='$txt',PageText='$data{'PageText'}',PageImg='$data{'PageImg'}',Upd='$upd'","ARID='$AR' AND PageID='$_[0]'");
# Redirect to Main
print "Location: " . URL_TO_CGI . "/website.cgi?user=$user\n\n";
}
Code:
# Add Menu and Page Header
my $catlist = &get_menu("$script");
# Swap DSN to AR
&swap_dsn("AR");
# Check which page text to get
my @hlp = "";
if($_[0] eq "index" or $_[0] eq "aboutus"){
@hlp = &getSQL("AR_Pages","PageTitle,PageText","ARID='$AR' AND PageID ='$_[0]'");
}
else {
@hlp = &getSQL("HLP_Pages","PageTitle,PageText","PageID='$_[0]'");
}
# Get Page Info
my @page = &getSQL("AR_Pages","PageTitleStyle,PageTextStyle,PageImg","ARID='$AR' AND PageID='$_[0]'");
###########################
# Split into style arrays #
###########################
# Font , size, colour, bgcol (if applicable)
my @ptit_style = split(/,/, $page[0]{'PageTitleStyle'});
my @ptxt_style = split(/,/, $page[0]{'PageTextStyle'});
my $oldtxt = uri_escape($hlp[0]{'PageText'});
# Continue with Main page
$catlist .= "
<TABLE width=\"85%\" >
<tr>
<td height=10 class=\"titlecell\" onmouseover=\"window.status='Please choose a menu option'\"> $_[1] Configuration</td>
</tr>
<tr>
<td>
<table>
<form name=\"arpage\" action=\"" . URL_TO_CGI . "/website.cgi\" method=\"post\">
<input type=\"hidden\" name=\"PageID\" value=\"$_[0]\">
<input type=\"hidden\" name=\"user\" value=\"$user\">
<tr >
<td width=\"260\">
<!--- User Selectable Images --->
<center>
<font style=\"font-size:14pt;\">Image : </font><select name=\"PageImg\" style=\"cursor:pointer\" onChange=\"document.PageImg.src='" . AR_URL_TO_WEB . "/images/' + document.arpage.PageImg.value;\">
<option value=\"$page[0]{'PageImg'}\">Please Select ($page[0]{'PageImg'})</option>";
# Get Images
my @img = glob(AR_DIR_TO_WEB . '/images/*');
# Loop & Build html select list
for(@img){
my $path = AR_DIR_TO_WEB . "/images/";
$_ =~ s/$path//g;
$catlist .= "<option value=\"$_\">Image($_)</option>";
}
$catlist .= "</select>
<img src=\"" . AR_URL_TO_WEB . "/images/$page[0]{'PageImg'}\" name=\"PageImg\" width=\"254\" height=\"400\">
</td>
<td valign=top width=315><center><font style=\"font-size:14pt;\">
Main Page Text</font><br>
<textarea name=\"PageText\" onFocus=\"$ronly\" id=\"PageText\" style=\"width:315px; height=400px; font-family:$ptxt_style[0]; font-size:$ptxt_style[1]pt; color:$ptxt_style[2]; background:$ptxt_style[3]; scrollbar-base-color:$ptxt_style[3]; scrollbar-shadow-color:$ptxt_style[2]; border:none;\" $_[2]>$hlp[0]{'PageText'}</textarea>
now before the display i've added this line
Code:
# sort out carriage returns for some reason
$hlp[0]{'PageText'} =~ s/\r\n\r\n/\r\n/g;
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.