Gossamer Forum
Home : Products : DBMan : Installation :

Error adding new records & modifying

Quote Reply
Error adding new records & modifying
This is what I have in default.cfg:
Code:
%db_def = (
Name => [1, 'alpha', 40, 255, 1, '', ''],
email => [2, 'alpha', 0, 60, 1, '', ''],
icq => [3, 'alpha', 0, 60, 1, '', ''],
URL => [4, 'alpha', 40, 255, 1, 'http://', '^http://'],
stats => [5, 'alpha', 40, 255, 1, '', ''],
Description => [6, 'alpha', '40x3', 500, 0, '', ''],
games => [7, 'alpha', 0, 500, 0, '', ''],
Userid => [8, 'alpha', -1, 15, 0, '', '']
);

# 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;

Plus, these are my admin things:
Code:
$auth_no_authentication = 0;

# The amount of time in seconds that user files are kept in the
# auth directory before the program removes them. 2-6 hours is
# probably a good value.
$auth_time = 21600; # 6 hours (in seconds)

# Enable (1) or disable (0) logging.
$auth_logging = 1;

# Allow a default user? This means you can specify a user via the URL
# and skip the logon process. Use this to allow people to search without
# logging on, but require log in if they want to add/modify/remove etc.
# (1 = "yes", 0 = "no")
$auth_allow_default = 1;

# Default permissions used if there is no authentication, or for a default
# user. (View, Add, Delete, Modify, Admin), 1 = enable, 0 = disable.
@auth_default_permissions = (1,0,0,0,0);

# Allow people to sign up for their own userid/passwords? They will
# recieve default permissions.
$auth_signup = 1;

# Permissions a new signup should get.
@auth_signup_permissions = (1,1,1,1,0);

# Registered users: can modify/delete _only_ own records. For this to make
# sense you should set default off or to 1,0,0,0.
$auth_modify_own = 1;

# Registered users: can view _only_ own records. For this to make sense
# you should turn off default permissions.
$auth_view_own = 0;

# Auth user field. This is the field position in the database used for storing
# the userid who owns the record. Set to -1 if not used.
$auth_user_field = 9;

What I want is for users to have to create a new account to login and add only 1 record. Each member can only modify or delete their own record.

I am having problems. I just created my admin, and added my own record. I'm testing it out (I chose to modify my own record, I did List All, and then pressed modify). It gave me this error: Can't find requested record.

Then, I had someone create a login, and add a record. They got this error while trying to login:
Error: Duplicate Key Error

Please help...I've been working on this database for so long, and I'm very thankful I've made it this far.
Quote Reply
Re: Error adding new records & modifying In reply to
I see two problems.

First, you must start numbering your fields with number 0. So your field definition should look like:

Code:
%db_def = (
Name => [0, 'alpha', 40, 255, 1, '', ''],
email => [1, 'alpha', 0, 60, 1, '', ''],
icq => [2, 'alpha', 0, 60, 1, '', ''],
URL => [3, 'alpha', 40, 255, 1, 'http://', '^http://'],
stats => [4, 'alpha', 40, 255, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
games => [6, 'alpha', 0, 500, 0, '', ''],
Userid => [7, 'alpha', -1, 15, 0, '', '']
);

The other problem is

$auth_user_field = 9;

With the new numbering of your fields, it needs to be

$auth_user_field = 7;

You should upload a new, empty default.db file and start over again.


------------------
JPD





Quote Reply
Re: Error adding new records & modifying In reply to
Okay, it seems to be working a little better now.

http://knightsofd.virtualave.net/cgi-bin/dbman/db.cgi

make a new sign in.

The only problem is, List all doesn't work the way I want. I want it to actualy list it, not show up the matches.

Doing Modify Record, List all does this:
It brings up 2 radio buttons, with no text beside them.

I don't see what is wrong.

http://knightsofd.virtualave.net/here/default_cfg.txt
http://knightsofd.virtualave.net/here/html_pl.txt

I did what you told me to do, I don't understand why it's not working though.
Quote Reply
Re: Error adding new records & modifying In reply to
You can't use $db_autogenerate with the short/long display mod.

The reason your "email" and "icq" fields are so small is that you have them both set with a field length of 0.



------------------
JPD





Quote Reply
Re: Error adding new records & modifying In reply to
I did this now, and now for the E-mail field when looking for a record to modify, it says this:
error building select field: no select fields specified in config for field 'Type'!
Code:
%db_def = (
Name => [0, 'alpha', 40, 255, 1, '', ''],
email => [1, 'alpha', 0, 60, 0, '', ''],
icq => [2, 'alpha', 0, 60, 0, '', ''],
URL => [3, 'alpha', 40, 255, 1, 'http://', '^http://'],
stats => [4, 'alpha', 40, 255, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
games => [6, 'alpha', 0, 500, 0, '', ''],
Userid => [7, 'alpha', -1, 15, 0, '', '']
);

and it still has the same problem with displaying the ones you want to modify, and list all doesn't display them.
Quote Reply
Re: Error adding new records & modifying In reply to
I think you need to start over from scratch. I'm at least as confused as you are, if not more so.

It might help for you to go to my site and follow the DBMan tutorial that begins at

http://www.jpdeni.com/dbman/tutorial.html

Follow each step along the way and, if you have any problems, come ask about them before you continue on.


------------------
JPD





Quote Reply
Re: Error adding new records & modifying In reply to
Okay...all I know is I did that yesterday (starting from scratch).

I'll keep working on it, maybe I just screwed something up =P
Quote Reply
Re: Error adding new records & modifying In reply to
Everything worked earlier, it's juss i didn't have that duplicate key error. Thanks for all your help...it's been a long week working on this thing.
Quote Reply
Re: Error adding new records & modifying In reply to
The script works so far!

Well, I think it does. If a normal user (not admin) tries to create more than 1 record, it messes up I think. I would rather have it show an error, because when it does add it, it shows "Record Added" but the fields are all blank. Then pressing List All it shows it, but they cannot modify it or delete it. I, the admin, can't modify it either (said record not found), but I am able to delete it.

Is there a better way to make it so that 1 normal login person can only make 1 record?
Quote Reply
Re: Error adding new records & modifying In reply to
Then you have something wrong in your setup.

What should happen when a user tries to add a second record, they will get a "duplicate key error."

Did you follow all the steps in the tutorial?


------------------
JPD





Quote Reply
Re: Error adding new records & modifying In reply to
Well, I skimmed through it. I basically installed the original database (I had to do the default, admin, add user, set authorization back to normal trick). I tested it out, everything worked.

So all I did from then on is edit the Name, Description and fields like that.

Code:
%db_def = (
name => [0, 'alpha', 40, 255, 1, '', ''],
email => [1, 'alpha', 0, 100, 0, '', ''],
icq => [2, 'alpha', 0, 25, 0, '', ''],
URL => [3, 'alpha', 40, 255, 1, 'http://', '^http://'],
stats => [4, 'alpha', 40, 255, 1, '', ''],
description => [5, 'alpha', '40x3', 500, 0, '', ''],
games => [6, 'alpha', 0, 500, 0, '', ''],
Userid => [7, 'alpha', -1, 15, 0, '', '']
);

# 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 = 1;
# Database delimeter.
$db_delim = '|';
# Use file locking (1 = Yes, 0 = No). Should be used, but won't work on Win95.
$db_use_flock = 0;
# 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;

# Checkbox fields. Field name => Checkbox value.
%db_checkbox_fields = ( games => 'Starcraft/Broodwar,Half-Life,Everquest,Tribes,Command and Conquer,Warcraft 2' );

# Default maximum number of hits returned in a search.
$db_max_hits = 10;
# Bold search results (1 = Yes, 0 = No).
$db_bold = 1;
# Regular and title fonts used in auto_generatrion and html.pl.
$font = 'font face="verdana,arial,helvetica" size="2"';
$font_title = 'font face="verdana,arial,helvetica" size="4"';

# Authorization Options
# --------------------------------------------------------
# No Authentication? (1 = "there is no authentication", 0 = "there is authentication")
# If you choose no authentication, then set the permissions of what
# people can do with: @auth_default_permissions below.
$auth_no_authentication = 0;

# The amount of time in seconds that user files are kept in the
# auth directory before the program removes them. 2-6 hours is
# probably a good value.
$auth_time = 21600; # 6 hours (in seconds)

# Enable (1) or disable (0) logging.
$auth_logging = 1;

# Allow a default user? This means you can specify a user via the URL
# and skip the logon process. Use this to allow people to search without
# logging on, but require log in if they want to add/modify/remove etc.
# (1 = "yes", 0 = "no")
$auth_allow_default = 1;

# Default permissions used if there is no authentication, or for a default
# user. (View, Add, Delete, Modify, Admin), 1 = enable, 0 = disable.
@auth_default_permissions = (1,0,0,0,0);

# Allow people to sign up for their own userid/passwords? They will
# recieve default permissions.
$auth_signup = 1;

# Permissions a new signup should get.
@auth_signup_permissions = (1,0,0,0,0);

# Registered users: can modify/delete _only_ own records. For this to make
# sense you should set default off or to 1,0,0,0.
$auth_modify_own = 1;

# Registered users: can view _only_ own records. For this to make sense
# you should turn off default permissions.
$auth_view_own = 0;

# Auth user field. This is the field position in the database used for storing
# the userid who owns the record. Set to -1 if not used.
$auth_user_field = 7;

And with the html.pl, all I did was change the text color, background color and table color. And changed the fields for Name, description, etc.
Quote Reply
Re: Error adding new records & modifying In reply to
I wrote the tutorial specifically for folks who are having trouble with the database. Skimming through it won't do it.

Here's your problem (or at least one problem):
Code:
# 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;

If you are using a userid as your key field you do *not* want to have $db_key_track=1. Set this to 0.

Here's another problem:
Code:
# Allow a default user? This means you can specify a user via the URL
# and skip the logon process. Use this to allow people to search without
# logging on, but require log in if they want to add/modify/remove etc.
# (1 = "yes", 0 = "no")
$auth_allow_default = 1;
# Default permissions used if there is no authentication, or for a default
# user. (View, Add, Delete, Modify, Admin), 1 = enable, 0 = disable.
@auth_default_permissions = (1,0,0,0,0);
# Allow people to sign up for their own userid/passwords? They will
# recieve default permissions.
$auth_signup = 1;
# Permissions a new signup should get.
@auth_signup_permissions = (1,0,0,0,0);
# Registered users: can modify/delete _only_ own records. For this to make
# sense you should set default off or to 1,0,0,0.
$auth_modify_own = 1;

Why should people sign up for accounts when they get no more permissions than people who don't sign up?

If users cannot add records, then the userid cannot be used for the key. And there's no point in setting $auth_modify_own = 1;, because there is no ownership of records.

Finally, if users can't add records and you are using the userid as the key, you will only have one record in your database.

Until everything in your fields works, you ought not to change anything in html.pl. You need to have $db_autogenerate = 1 until you have tested your fields and you know that they are doing what you want them to do. Otherwise, when you have a problem, you don't know what the cause of it is.

Before you were using the short/long display mod. You didn't say if you were using it this time around, but if you are, don't. Don't use it until you have everything else working.


------------------
JPD