This topic is locked

Adding New Detail Records - HELP!

5/31/2005 3:24:52 PM
PHPRunner General questions
roy author

Help! I'm trying to add "real" records to my database using PHPRunner, and the wrong Master Record Key is being assigned to the Detail.
The Businesses table is the Master and; Contacts and Contracts are Detail tables linked to the Businesses.
For each Business there may be 1 or more Contacts and 1 or more Contracts.
Businesses (Master)

+------------+-----------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+------------+-----------------+------+-----+---------+----------------+

| busid | int(5) unsigned | | PRI | NULL | auto_increment |

| busname | varchar(30) | YES | MUL | NULL | |

| busaddr1 | varchar(30) | YES | | NULL | |

| buscity | varchar(25) | YES | | NULL | |

| busstate | char(2) | YES | | NULL | |

| buszip | varchar(10) | YES | | NULL | |

| busphone | varchar(20) | YES | | NULL | |

| busfax | varchar(20) | YES | | NULL | |

+------------+-----------------+------+-----+---------+----------------+
Contacts (Detail) - Link field is cnbusid

+-------------+-----------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+-------------+-----------------+------+-----+---------+----------------+

| contactid | int(5) unsigned | | PRI | NULL | auto_increment |

| cnbusid | int(5) unsigned | | MUL | 0 | |

| fname | varchar(15) | YES | | | |

| lname | varchar(25) | YES | | | |

| ophone | varchar(20) | YES | | NULL | |

| cphone | varchar(20) | YES | | NULL | |

| email | varchar(35) | YES | | NULL | |

+-------------+-----------------+------+-----+---------+----------------+
Contracts (Detail) - Link field is ctbusid

+------------+---------------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+------------+---------------------+------+-----+---------+----------------+

| contractid | int(7) unsigned | | PRI | NULL | auto_increment |

| ctbusid | int(5) unsigned | | MUL | 0 | |

| market | tinyint(3) unsigned | | | 0 | |

| zone | char(1) | | | A | |

| volume | tinyint(3) unsigned | | | 0 | |

| issue | tinyint(3) unsigned | | | 0 | |

| section | varchar(15) | YES | | | |

| ad_size | tinyint(3) unsigned | | | 0 | |

+------------+---------------------+------+-----+---------+----------------+
When I get a new Contract for a new Business, I add the Business table information via the "Add New" button on the Businesses list page and, of course, that works just fine. I then display the Contracts for that Business via the "Contracts" detail link on the Business list page. At this point there are no Contracts for this Business, so I add the Contract table information via the "Add New" button on the Contract list page. The Master (Business) record displayed on the Contract list (detail) page is the one that I just added - the right one.
The Contract table record gets added, but it is pointing to the wrong Business table entry. At first, I thought it was pointing to the 1st entry in the Business table, but that's not the case. It seems to be fairly random in it's assignment.
Everything I just said is also true when I attempt to add a Contract table entry.
I need to get this fixed, as I don't want the person who is entering the data to have to look up the Master key (Business) from a look up wizard. There will be way too many entries for that.
Help!

roy author 5/31/2005

This problem gets more and more mysterious. I suspect that the Master/Detail problem described above is linked to the Session Expired problem I'm also having.
My reason for this suspision is that this problem only manifests itself on the same computer that is experiencing the session expired problem and does not manifest itself on my computer at home running the exact same code.

pplaut 5/31/2005

Is this a mySQL database?

If it is try downloading the MySQL administrator

http://dev.mysql.com/downloads/administrator/1.0.html
Backup the databases, it makes a nice tidy little script like this...
CREATE TABLE `mos_tsg_license` (

`email_address` varchar(45) NOT NULL default '',

`lic_first_name` varchar(45) NOT NULL default '',

`lic_last_name` varchar(45) NOT NULL default '',

`lic_city` varchar(45) NOT NULL default '',

`lic_reg_number` varchar(45) NOT NULL default '',

`lic_reg_key` varchar(45) NOT NULL default '',

PRIMARY KEY (`email_address`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='License Verification';
This makes it a lot easier to follow the sql structure.
Peer

roy author 6/1/2005

Thanks Peer,

Yes, it's a mtSQL database. I apologize for the sloppy screen captures of an SQL Explain table output. I should have taken the time to extract them from the .sql file generated by administrator. You are right, the Administrator is great, I use it all the time.
The easier to read schemas follow:
CREATE TABLE `businesses` (

`busid` int(5) unsigned NOT NULL auto_increment,

`busname` varchar(30) default NULL,

`busaddr1` varchar(30) default NULL,

`busaddr2` varchar(30) default NULL,

`buscity` varchar(25) default NULL,

`busstate` char(2) default NULL,

`buszip` varchar(10) default NULL,

`busphone` varchar(20) default NULL,

`busfax` varchar(20) default NULL,

`buswebsite` varchar(50) default NULL,

`busstatus` char(2) default NULL,

`buscoords` varchar(20) default NULL,

PRIMARY KEY (`busid`),

KEY `busname` (`busname`)

) TYPE=InnoDB;
CREATE TABLE `contacts` (

`contactid` int(5) unsigned NOT NULL auto_increment,

`cnbusid` int(5) unsigned NOT NULL default '0',

`title` varchar(15) default '',

`fname` varchar(15) default '',

`lname` varchar(25) default '',

`dept` varchar(15) default NULL,

`ophone` varchar(20) default NULL,

`cphone` varchar(20) default NULL,

`email` varchar(35) default NULL,

`birthday` date default NULL,

`special_dt` date default NULL,

`anniversary` date default NULL,

`spouse` varchar(15) default NULL,

`children` varchar(255) default NULL,

`notes` varchar(255) default NULL,

PRIMARY KEY (`contactid`),

KEY `cnbusid` (`cnbusid`),

CONSTRAINT `contacts_ibfk_1` FOREIGN KEY (`cnbusid`) REFERENCES `businesses` (`busid`)

) TYPE=InnoDB;
CREATE TABLE `contracts` (

`contractid` int(7) unsigned NOT NULL auto_increment,

`ctbusid` int(5) unsigned NOT NULL default '0',

`market` tinyint(3) unsigned NOT NULL default '0',

`zone` char(1) NOT NULL default 'A',

`volume` tinyint(3) unsigned NOT NULL default '0',

`issue` tinyint(3) unsigned NOT NULL default '0',

`section` varchar(15) default '',

`ad_size` tinyint(3) unsigned NOT NULL default '0',

PRIMARY KEY (`contractid`),

KEY `ctbusid` (`ctbusid`),

CONSTRAINT `contracts_ibfk_1` FOREIGN KEY (`ctbusid`) REFERENCES `businesses` (`busid`)

) TYPE=InnoDB;
Do you have any thoughts regarding the problem with adding records?
Thanks,

Roy

Sergey Kornilov admin 6/1/2005

Roy,
it seems that this problem is related to Session expired issue

Did you receive my last email about that ?

Here it is.

Roy,
I see what you saying.
I use script expiration mechanism to find if fresh PHP files were uploaded to the Web server. As far as I understand this doesn't work as expected on your Web server.
Please download updated version of PHPRunner where I do not use this schema anymore. Let me know if it works fine.
http://www.asprunner.com/forums/index.php?showtopic=1340
Feel free to contact me if you need any help.
roy author 6/1/2005

Yes, Sergey, I did receive that email. I was already using v2.0 beta 2 but, I downloaded v2.0 beta 2 again and reinstalled PHPRunner. The problem persisted!
At your request, I have since sent you the project file, the database, and the php.ini files from both computers via email to support@xlinesoft.com. Did you receive them? Let me know at roymaul@yahoo.com.
I have set up another box with WinXP Pro SP2, Apache2.0.54, PHP5.0.4, and mySQL4.1.7. I transferred the generated code folder from the laptop to the new box and the problem persists.
I have done this transfer on several occaisons to my box at home, equipped as above, and have not experienced any problems.
This is really frustrating me! I don't have the proficiency or understanding of PHP, or the time to develop it, to dig into the code and tweak it. Am I trying to do something that's beyond PHPRunner? From what I've seen that it can do, I rather doubt that.
Thank you,

Roy

roy author 6/2/2005

After prleo1 posted the following on Jun 1 2005, 08:27 PM,

Found out the stupid issue.

For some reason there was a \ in my session.cookie_path instead of a /.

After changing, no issue.

I thought I would check for that kind of error in the php.ini files on my offending machines. No dice, all the slashes had the right leaning. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=4659&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

pplaut 6/2/2005

I want to make sure I am clear on this..............

You have master table called business............say for a customer lets say.

You then have a detail table called contacts...... say for contacts within that business

You then have a detail table off the master business called contracts........... for the contracts with each business....
OK, so that should work I am doing similar things.................

However today, I may have had a similar issue where I was adding detail records and had to go back to the list.php to get back to the master table. I had seen this before, but this was early on in one of my very simple "starter" projects.
I am running this app on W2K server with IIS.

I have not "rebuilt the app" with the latest download.

I am wondering if that is what the good folks at PHPRunner are suggesting to get rid of the problem?
Peer

roy author 6/2/2005

Yes, that is exactly what they are suggesting. However, I have done that several times and it isn't working.
Your description of my database is correct and I consider it to be pretty straight forward and typical. I have experienced the situation you have described on a few occasions, but the big problem is that I'm actually experiencing detail records being linked to the wrong master. Also, I'm experiencing session expired errors.
To be entirely fair, this is a strange problem that occurs on 2 out of 3 systems I have tried to run the code on. The code is generated on 1 of the failing machines and, when transported to 2 identical machines, it fails on 1 and performs properly on the other.
Roy