I'm trying to get a number of how many records are in the DB I call toby to show on the master page.
Below is the code that I'm using, the path to "toby.db" is correct but I don't get a number to show.
What my end goal is, is to have and image show on a page (like a red bar) if there is one record or more in the data base
If there are no records then the image will not show.
Records are in this DB for a short time then deleted. The red bar will tell admin that there is a record in the DB.
You may know of a better way than what I'm thinking.
Any ideals?
Ed-
################################################################
cfg
################################################################
# Full path to toby database.
$db_file_toby = $db_script_path . "/../db/toby.db"; # This is the name of the Toby's DB.
################################################################
db.cgi
################################################################
sub db_record_count {
# --------------------------------------------------------
# Displays the number of records.
my $count = 0;
open (DB, "<$db_file_toby") or &cgierr("error. unable to open database:$db_file_toby.\nReason: $!");
LINE: while ( ) {
if (!(/^#/) && !(/^\s*$/)) {
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($per_admin) {
++$count;
}
}
}
close DB;
print $count;
}
################################################################
html.pl
################################################################
This is a test to see if it will print a number: $db_record_count
Below is the code that I'm using, the path to "toby.db" is correct but I don't get a number to show.
What my end goal is, is to have and image show on a page (like a red bar) if there is one record or more in the data base
If there are no records then the image will not show.
Records are in this DB for a short time then deleted. The red bar will tell admin that there is a record in the DB.
You may know of a better way than what I'm thinking.
Any ideals?
Ed-
################################################################
cfg
################################################################
# Full path to toby database.
$db_file_toby = $db_script_path . "/../db/toby.db"; # This is the name of the Toby's DB.
################################################################
db.cgi
################################################################
sub db_record_count {
# --------------------------------------------------------
# Displays the number of records.
my $count = 0;
open (DB, "<$db_file_toby") or &cgierr("error. unable to open database:$db_file_toby.\nReason: $!");
LINE: while ( ) {
if (!(/^#/) && !(/^\s*$/)) {
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($per_admin) {
++$count;
}
}
}
close DB;
print $count;
}
################################################################
html.pl
################################################################
This is a test to see if it will print a number: $db_record_count