Gossamer Forum
Home : Products : DBMan : Installation :

help with add record and modify

Quote Reply
help with add record and modify
I am getting a blank add_success screen when adding a new record and also when I modify it doesn't modify but adds a new record leaving the old one there as well. I have enclosed the subroutines that i suspect are the culprits but I can't figure it out. Much obliged if anyone can spot my error.

sub html_add_success {
# --------------------------------------------------------
# The page that is returned upon a successful addition to
# the database. You should use &get_record and &html_record
# to verify that the record was inserted properly and to make
# updating easier.

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Record Added.</title>
</head>

<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Record Added</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Record Added
</b></font></center><br>
<$font>
<P><Font face="Verdana, Arial, Helvetica" Size=2>The following record was successfully added to the database:</FONT>
|; &html_record(&get_record($in{$db_key})); print qq|
</font></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}
and
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
$rec{'Quote'} =~ s/\n/<br>/g;
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
if ($rec{'Category'} ne $tmp_category ){
&tmp_category;
}
print qq|<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="ffffff">
<FONT FACE="MS Sans Serif, arial,helvetica" size=2 COLOR="#000000">
<center><br>$rec{'Quote'}<br></center><p>Submitted: $rec{'Date'}</p>
</td></tr></table>|;

}
sub tmp_category{
my (%rec) = @_;
($db_auto_generate and print &build_html_record(%rec) and return);
$number_of_categories++;
$tmp_category=$rec{'Category'};
print qq|<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=2 COLOR="#FFFFFF">
<b><center><em>$tmp_category</em></center></b>
</td></tr></table>|;
I have not edited anything in the modify section of html.pl so I don't think that is where the problem is. I suspect it is in html_record where I change categories.
Quote Reply
Re: help with add record and modify In reply to
What is the proper code to only execute this line when this sub is called from view_success only? I think that would solve my problem.
if ($rec{'Category'} ne $tmp_category ){
&tmp_category;
}
Quote Reply
Re: help with add record and modify In reply to
I don't know if this is your problem or not, but I see a little problem with your sub tmp_category. Since you're using my (%rec) = @_; in html_record, the %rec hash is only available to html_record. If you want to use the variable in sub tmp_category, you have to pass it to the subroutine:

&tmp_category(%rec);

You could also just put it in html_record if you wanted, but that's a matter of preference.

Blank screens usually mean that there's a table that's not closed off. Or possibly that there was an error. Turn your debug on and see what happens. If you still get a blank screen, look at the source of the page (View/Page Source in Netscape -- something similar in Internet Explorer). You may find some info at the bottom of the page.

If you don't get any cgi errors on it, there is probably a problem with your html code that isn't really obvious. These are real tough to find sometimes.

As for the modify problem, I don't see how it would be related to the html_record subroutine. The only thing I can think of right now is that you may not have a field for your $db_key field defined in html_record_form.

Quote:
What is the proper code to only execute this line when this sub is called from view_success only? I think that would solve my problem.
if ($rec{'Category'} ne $tmp_category ){
&tmp_category;
}

I think calling it from html_view_success might cause you more problems than it would solve.

------------------
JPD
Quote Reply
Re: help with add record and modify In reply to
Thanks JP. I guess I didn't specify my problem well enough. I am not getting a blank screen as such but rather getting a screen that shows the record layout with blank data. Unfortunately I don't know perl at all so I really don't know what I have done.