Gossamer Forum
Home : Products : DBMan : Customization :

Another Relational Mod Problem! :(

Quote Reply
Another Relational Mod Problem! :(
I've now got another relational mod problem. In my search form I have the following fields that users are allowed to search by:

Make (item database)
Model (item database)
Category (item database)
Year (item database)
Price (item database)
Region (user database)

The fields in the item database can all be found but the "Region" field brings up the error "error building select field: no select fields specified in config for field Region!". I've looked at the code so many times and haven't been able to find a problem.

Hopefully someone here can see it :)

Here are my files:

---------
item.cfg
---------
# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr']

%db_def = (
'UserID' => [0, 'alpha', 20, 255, 1, '', ''],
'ItemID' => [1, 'numer', 5, 5, 1, '', ''],
'Make' => [2, 'alpha', 20, 15, 1, '', ''],
'Model' => [3, 'alpha', 20, 50, 1, '', ''],
'Category' => [4, 'alpha', 20, 15, 1, '', ''],
'Year' => [5, 'alpha', 20, 4, 1, '', ''],
'Mileage' => [6, 'alpha', 20, 10, 1, '', ''],
'Price' => [7, 'alpha', 20, 10, 1, '', ''],
'Colour' => [8, 'alpha', 20, 15, 1, '', ''],
'Description' => [9, 'alpha', 40x5, 1000, 1, '', ''],
'ABSBraking' => [10, 'alpha', 0, 18, 0, '', ''],
'AlloyWheels' => [11, 'alpha', 0, 18, 0, '', ''],
'PowerSteering' => [12, 'alpha', 0, 18, 0, '', ''],
'AirConditioning' => [13, 'alpha', 0, 18, 0, '', ''],
'CentralLocking' => [14, 'alpha', 0, 18, 0, '', ''],
'ElectricWindows' => [15, 'alpha', 0, 18, 0, '', ''],
'StereoSystem' => [16, 'alpha', 0, 18, 0, '', ''],
'CDPlayer' => [17, 'alpha', 0, 18, 0, '', ''],
'TowBar' => [18, 'alpha', 0, 18, 0, '', ''],
'SunRoof' => [19, 'alpha', 0, 18, 0, '', ''],
'Spoiler' => [20, 'alpha', 0, 18, 0, '', ''],
'StockNo' => [21, 'alpha', 0, 255, 1, '', ''],
'Filename' => [23, 'alpha', 0, 255, 0, '', ''],
'Graphic' => [24, 'alpha', 0, 3, 0, '', 'Yes'],
'DateAdded' => [25, 'date', 20, 255, 1, &get_date(), '']
);

# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'ItemID';
# Track the key? Should DBMan keep a counter of the next key to use? This isn't
# neccessary if you can guarantee that your entry in the key field will be unique
# (i.e. a userid).
$db_key_track = 1;

------------
user.cfg
------------

# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr']

%db_def = (
'UserID' => [0, 'alpha', 20, 255, 1, '', ''],
'IMVDARef' => [1, 'alpha', 20, 255, 1, '', ''],
'CompanyName' => [2, 'alpha', 20, 255, 1, '', ''],
'PhysicalAddress' => [3, 'alpha', 40x3, 255, 1, '', ''],
'PostalAddress' => [4, 'alpha', 40x3, 255, 1, '', ''],
'Region' => [5, 'alpha', 20, 255, 1, '', ''],
'RetailWholesale' => [6, 'alpha', 20, 255, 1, '', ''],
'Phone' => [7, 'alpha', 20, 255, 1, '', ''],
'Fax' => [8, 'alpha', 20, 255, 1, '', ''],
'Email' => [9, 'alpha', 20, 255, 1, '', ''],
'Website' => [10, 'alpha', 20, 255, 1, '', ''],
);

# The column name for the database key. Can be any column, but it must be unique!
# You can't have two records with the same key value!
$db_key = 'UserID';
# Track the key? Should DBMan keep a counter of the next key to use? This isn't
# neccessary if you can guarantee that your entry in the key field will be unique
# (i.e. a userid).
$db_key_track = 0;
# Database delimeter.
$db_delim = '|';
# Use file locking (1 = Yes, 0 = No). Should be used, but won't work on Win95.
$db_use_flock = 1;
# Auto generate the html forms (1 = Yes, 0 = No).
$db_auto_generate = 0;
# Display Benchmarking Information (1 = Yes, 0 = No).
# use Benchmark; # Uncomment this line if benchmarking is used.
$db_benchmark = 0;
# Display Debugging Information (1 = Yes, 0 = No).
$db_debug = 0;

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
'Region' => 'Northland,Auckland,Waikato,Taranaki,Wanganui,Manawatu,Wellington,Wairarapa,Hawkes Bay,Gisborne,Bay of Plenty,Nelson & Bays,West Coast,Southland,Otago,Timaru/Oamaru,Christchurch,Marlborough',
'RetailWholesale' => 'Retail,Wholesale'

);

------------
format.pl
------------


sub switch_to_item {
#-----------------------------------------------------
$cols = 'UserID,ItemID,Make,Model,Category,Year,Mileage,Price,Colour,Description,ABSBraking,AlloyWheels,PowerSteering,AirConditioning,CentralLocking,ElectricWindows,StereoSystem,CDPlayer,TowBar,SunRoof,Spoiler,StockNo,Filename,Graphic,DateAdded';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/item.db";
$db_sort{'DateAdded'} = 'date';
}

sub switch_to_user {
#-----------------------------------------------------
$cols = 'UserID,IMVDARef,CompanyName,PhysicalAddress,PostalAddress,Region,RetailWholesale,Phone,Fax,Email,Website';
@db_cols = split /,/,$cols;
$db_file_name = $db_script_path . "/user.db";
$db_key_pos = 0;
}

----------
item_html.pl
-----------

sub html_search_form {
# --------------------------------------------------------

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);

my $font = 'Font face="geneva,verdana,arial,helv,sans-serif" Size=2 Color=#003399';

print qq|

<font color="#FFFFFF" size="10">CONSUMER SEARCH</FONT>

<TABLE WIDTH="100%" CELLPADDING=0 CELLSPACING=0 BORDER=0>


<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="geneva,verdana,arial,helv,sans-serif" Size=2 color="#FFFFFF"><b>Make:</b> </FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("Make", "$rec{'Make'}"); print qq|</TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="geneva,verdana,arial,helv,sans-serif" Size=2 color="#FFFFFF"><b>Model:</b></FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Model" VALUE="$rec{'Model'}" SIZE="20" MAXLENGTH="255"></TD></TR>

<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="geneva,verdana,arial,helv,sans-serif" Size=2 color="#FFFFFF"><b>Category:</b></FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("Category", "$rec{'Category'}"); print qq|</TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="geneva,verdana,arial,helv,sans-serif" Size=2 color="#FFFFFF"><b>Year:</b></FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Year" VALUE="$rec{'Year'}" SIZE="4" MAXLENGTH="4"></TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="geneva,verdana,arial,helv,sans-serif" Size=2 color="#FFFFFF"><b>Price:</b></FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Price" VALUE="$rec{'Price'}" SIZE="10" MAXLENGTH="12"></TD></TR>
<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="geneva,verdana,arial,helv,sans-serif" Size=2 color="#FFFFFF"><b>Region:</b></FONT></TD>
<TD VALIGN="TOP"> |; print &build_select_field ("Region",$rec2{'Region'}); print qq|</TD></TR>


</TABLE>
|;
}

------

Can someone please have a look at this and try and find a solution for me.

Cheers.

P.S If you need to see anymore of my files please let me know.

Quote Reply
Re: Another Relational Mod Problem! :( In reply to
Hi Philip, it would appear you do not have "Region" defined as a select field in your config file.

'Region' => [5, 'alpha', 20, 255, 1, '', ''],

Should be
'Region' => [5, 'alpha', 0, 255, 1, '', ''],

if this is intended to be a select field.


Quote Reply
Re: Another Relational Mod Problem! :( In reply to
Also you can not search for fields within two databases.

There is a way of searching two databases using radio button to specific which database.

You can find examples in the FAQ noted below under "Searching" or "Multi & Relational"


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Another Relational Mod Problem! :( In reply to
Oh ok.

Thanks for your comments Karen and LoisC!! :)