Gossamer Forum
Home : Products : DBMan : Customization :

Skipping blank fields

Quote Reply
Skipping blank fields
Ok... Here's the deal. I play a "SIM"ulated horse game that I'm a big part of, and I'm in charge of all the databases because I have the most experience with them. I've gotten everything working fine, but then I decided I wanted to try something new. In the game, your horse is awarded points for things, and there are "Titles" that they get when they achieve 100, 300, 500, 1000, etc. points. Since it takes 100 points to get a title, a lot of horses don't have one. What I want to do is say in my record "Horse has achieve Legandary Horse status on (Date they achieved it)" IF I have a title entered in the title field. If there ISN'T a title entered, I want it to say "Horse has not yet achieved any titles." or something. But everytime I do that, it comes up as having an internal error. So here's what I've got in my sub_html_record (I made bold the part that I'm talking about):

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.
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'Font face="Arial" Size="1" Color=#000000';
my $font = 'Font face="Arial" Size="1"';

$url{'Owner'} = $rec{'Owner'};
$url{'Owner'} =~ s/<\/?B>//g;
$rec{'Training'} =~ s/\n/<BR>/g;
$rec{'Organizations'} =~ s/\n/<BR>/g;
print qq|
<TABLE WIDTH="350" CELLPADDING=2 CELLSPACING="0" style="border: 1px #000000 solid" bgcolor="#949C94">
<tr>
<td width="100%" colspan="2" style="border-bottom: 1px #000000 solid" bgcolor="#949C94"><b><font face="Arial" size="2">$rec{'Horse'}&nbsp;$rec{'Title'}&nbsp;(#$rec{'Registration'})</font></b></td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><i><font size="1" face="Arial">($rec{'Sire'}&nbsp;x&nbsp;$rec{'Dam'})</font></i></td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><font size="1" face="Arial">$rec{'Age'}&nbsp;$rec{'Color'}&nbsp;$rec{'Breed'}&nbsp;$rec{'Gender'}&nbsp;($rec{'Height'})<br>
Currently resides at&nbsp;$rec{'Stabled At'}</font></td>
</tr>
<tr>
<td width="25%" bgcolor="#DEE7DE" valign="top"><font size="1" face="Arial"><u>Training</u><br>
$rec{'Training'}</font></td>
<td width="75%" valign="top" bgcolor="#DEE7DE"><font size="1" face="Arial"><u>Markings</u><br>
$rec{'Markings'}</td>
</tr>

<tr>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><font size="1" face="Arial">$rec{'Horse'}&nbsp;came
into OtB with&nbsp;$rec{'ImportedPoints'}&nbsp;points.</font></td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><font size="1" face="Arial">$rec{'Horse'}&nbsp;
currently has a total of&nbsp;$rec{'Points'}&nbsp;points.</font></td>
</tr>

<TR>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><$font_color><font size="1" face="Arial">
|;
}

if ($rec{'Title'}) {
print qq|
$rec{'Horse'}&nbsp;
reached the&nbsp;$rec{'Title'}&nbsp;status on&nbsp;$rec{'Date Title'}.
|;
}
else {
print qq| <TR>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><$font_color><font size="1" face="Arial">$rec{'Horse'}&nbsp;
has not yet reached the status of any of OtB's titles.</font></td></TR> |;
}

print qq|
</font></td></TR>


<tr>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><font size="1" face="Arial">$rec{'Horse'}&nbsp;last
saw the vet on&nbsp;$rec{'Vet'}.</font></td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><font size="1" face="Arial">$rec{'Horse'}&nbsp;last
saw the farrier on&nbsp;$rec{'Farrier'}.</font></td>
</tr>
<tr>
<td width="25%" valign="top" bgcolor="#DEE7DE"><font size="1" face="Arial"><u>Organizations</u><br>
$rec{'Organizations'}</font></td>
<td width="75%" valign="top" bgcolor="#DEE7DE"><font size="1" face="Arial"><u>Previous Owners</u><br>
$rec{'Owners'}</font></td>
</tr>

<tr>
<td width="100%" valign="top" colspan="2" bgcolor="#DEE7DE"><font size="1" face="Arial">For
more information on $rec{'Horse'}, contact&nbsp;<a href="mailto:$url{'Owner'}">$rec{'Owner'}</a>.</font></td>
</tr>


</TABLE>
|;
}

Now, even if I take out the ELSE statement, it still doesn't work. I've tried putting the table tags inside and outside of the print qq||; and it just brings up the internal error statement. Can anyone help me to get this to work?

(Also, all of my CHMods are correct and it was uploaded under ASCII. If I take out the IF statement, it works fine. But as soon as it's included, it screws up.)

Thanks so much,
-Reyhan

Last edited by:

Reyhan: Jul 24, 2004, 3:34 PM
Quote Reply
Re: [Reyhan] Skipping blank fields In reply to
Try removing the ending bracket before your if statement:

<TR>
<td width="100%" colspan="2" bgcolor="#DEE7DE"><$font_color><font size="1" face="Arial">
|;
} --- here

if ($rec{'Title'}) {


By having that closing bracket you are closing the sub before it can carry out the if ($rec{'Title'}) { and whatever is below it.

Hope that solves your problem.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Skipping blank fields In reply to
Okay, it worked as in it let me log in, and it let me add one that had a title and such. But when I tried to add one that didn't have a title, it gave me a 500 server error. Not sure what that's about. I think I'll just give up on that. Thanks so much for the help. I would never have figured that out myself.

I also have another question...

I think I saw something in another post about how to use a >7 in your IF statement to ignore the default http:// in a URL field. This has nothing to do with a URL field, rather the greater than idea.

Here is the range for the titles:

100 Champion (CH)
350 Local Champion (LCH)
500 Regional Champion (RCH)
750 National Champion (NCH)
1,000 International Champion (ICH)
1,750 Historical Champion (HCH)
2,250 Extreme Champion (XCH)
3,000 Supreme Champion (SCH)


and the set-up is $rec('horse)&nbsp;$rec('title')&nbsp;#$rec('Registration) so that it looks like "Starlight ICH #001" in the header row of my table. Now, I've got all of that set up to where I enter the title in manually. What I was wondering if is possible, can I set it up to where if the horse has >100 points it says CH after the name, >350 points it says LCH after the name, >500 it says RCH after the name, and so on and so forth, doing this all automatically. Also, if the horse has <100 points, the title should not show up at all. No space or anything. Just appearing like $rec('horse')&nbsp;#$rec('Registration'). I hope I explained that well enough. (Also, I'm only using the initials).

Once again, Thanks so much for your help, Lois, on the first question. My fellow gamers told me it wasn't necessary, so I won't be trying to fix that 500 server error when I add one without a title, unless it affects the second question that I asked just now. I'm so sorry for having you figure out how to help me when I now am not going to be using it. Really, I'm very very very sorry Unsure

|Edit|
Goodness... I'm having a horrible time with my databases!

This is a completely different database, for the same site. This one keeps track of the members and their stats.

http://www.onthebitsim.com/cgi-bin/cdb/db.cgi
(User ID: test and Pass: test)
It won't let me modify. I have no clue what is wrong. It says it can't find the specified record. I was thinking it was the fact that my User IDs are all three digits, starting with 001, 002, 003, etc. but when I added a record with the ID 100, it says "No search terms specified." which has me completely lost. And now that I think about it, it doesn't work for viewing either. Is it a problem with my field? Any idea as to what is wrong? (Also, about the 001, 002 idea, that works fine for my other database, with no problems modifying, deleting, or viewing).

Thanks so much for ANY help. Programming languages really are a tiny bit above me, and I get lost very easily with them. You guys are like, my life savers when it comes to errors that I have with them.

Last edited by:

Reyhan: Jul 24, 2004, 8:53 PM
Quote Reply
Re: [Reyhan] Skipping blank fields In reply to
I'm checking the forum very early in the morning and i might have an idea to get the points code to display, but dont' have time to modify some exisiting code and post it ... will work on it first thing tomorrow when I wake up.

Can't guarantee it will work without being able to test in with a live database, but it will perhaps give you some ideas to work with.

As far as your other database, the first thing to check would be to make sure your database did not become corrupt for some reason. The easiest way to check this would be to open up the file in Excel and scan all the fields to make sure the data is all in the correct fields.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Skipping blank fields In reply to
Please note I'm not a programmer and this is completely untested, but would be worth a try to see if it works. Hopefully someone with more knowledge of programming will come along and help get this to work if you have any problems.

I've taken the basics from the shopping cart mod (Ordernary) which uses this method to calculate shipping charges.

########## add this section to your .cfg file #########

$points1 = CH;
$points1_limit = 100;

# points up to points2_limit
$points2 = LCH;
$points2_limit = 350;

# points up to points3_limit
$points3 = RCH;
$points3_limit = 500;

# points up to points4_limit
$points4 = NCH;
$points4_limit = 750;

# points up to points5_limit
$points5 = ICH;
$points5_limit = 1000;

# points up to points6_limit
$points6 = HCH;
$points6_limit = 1750;

# points up to points7_limit
$points7 = XCH;
$points7_limit = 2250;

# points up to points8_limit
$points8 = SCH;
$points8_limit = 3000;

# points over points9_limit
$points9 = SCH;

########## end of .cfg file addition #########

I would make your 'title' field available to admin only so it can't be modified manually by others. You may have problems if you points contain a comma.

This portion you would put within your db.cgi file - sub add_record prior to the line:

$status = &validate_record; # First we validate the record to make sure the addition is ok.


## point calculation for title ###
$title = $total_points;

$in{'points'} =~ s/,//g; ### remove comma from entry


if ($total_points > 100) {
$points = $points1;
}
if (( $total_points > $points1_limit) && ( $total_points < $points2_limit)) {
$points = $points2;
}
if (( $total_points > $points2_limit) && ( $total_points < $points3_limit)) {
$points = $points3;
}
if (( $total_points > $points3_limit) && ( $total_points < $points4_limit)) {
$points = $points4;
}
if (( $total_points > $points4_limit) && ( $total_points < $points5_limit)) {
$points = $points5;
}
if (( $total_points > $points5_limit) && ( $total_points < $points6_limit)) {
$points = $points6;
}
if (( $total_points > $points6_limit) && ( $total_points < $points7_limit)) {
$points = $points7;
}
if (( $total_points > $points7_limit) && ( $total_points < $points8_limit)) {
$points = $points8;
}
elsif ($total_points > $points8_limit) {
$points = $points9;
}
}


Then in your html.pl file to add back the commas in your points field at the top of sub html_record after:

my (%rec) = @_; # Load any defaults to put in the VALUE field.

add:

$points = sprintf("%.2f",$points);

change this if your points field is not defined as "points" (case sensitive)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Skipping blank fields In reply to
Okay... I tried it, and it didn't work. I got a 500 Internal Server Error. I'm thinking this may be because I didn't know where in the .cfg file to place what you gave me.

And I have yet another question. When I go to search for modifying and don't use the Key field, then it brings up a list of matching records, like it should. But when I select one of the fields for modifying, the "Modify Record" button doesn't work. I installed the Modify Multiple Records at one MOD that JPDeni provides on the site, which works, but could that maybe have something to do with it?
Quote Reply
Re: [Reyhan] Skipping blank fields In reply to
For the above code try removing the last closting bracket:

}
} -- remove this one.

I was sure you would have to play around with the codes to get it to work.

You would add the codes in yoru .cfg file somwhere before the section:

# Database Definition

I'm not sure what is causing your modify problem. I haven't used the modify multiple records mod so am not familiar with any problems that could arise with using it. Did everything work before you added that mod?

Are you saving a copy of each revision so that you can go back to a previous working version and then go from there to troubleshoot the database?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Skipping blank fields In reply to
Well, I can't get the title thing to work. I'll just have to enter everything manually. Thanks so much for your help, Lois. I tried everything I could think of to get that script to work, but it just didn't. The DB would run and everything worked just fine, but the titles never showed. If you've any ideas, I'm still willing to try.

I'm not sure if everything worked before the mod. I don't modify that often at this time, but when our game gets started, things will be modified many times a day, which is why I'm worried. I'm not sure what you meant in the last post you made about the excel thing? What should I paste into Excel?

And yes, I keep a back up of all my files. I learned that a while ago after losing a lot of data Unsure
Quote Reply
Re: [Reyhan] Skipping blank fields In reply to
You would open your .db file within excel. Don't save it in excel ... just use that program to view all fields and make sure the fields are all where they are supposed to be.

What you could do to figure out why the modify is not working .. is make a backup copy of your files. Then take the original html.pl file and paste in your html_record_form and html_record subs and then test the add, modify, delete and see if everything works.

Are you fields numbered consecutively in your .cfg file? If not, that will sometimes cause problems when modifiying.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/