Come suggeritomi da Satifal e Oly1984 in una precedente discussione vorrei relazionare due tabelle MySql, ma mi succede una cosa strana...
Questo è il codice di riferimento:
Dovrebbe funzionare più o meno così: quando inserisco i dati nel form i dati di login (+nome e cognome) vanno nella prima tabella, mentre gli altri dati aggiuntivi nella seconda.Codice PHP:CREATE TABLE `users` (
`id` int(4) UNSIGNED NOT NULL AUTO_INCREMENT,
`nome` varchar(20) NOT NULL,
`cognome` varchar(20) NOT NULL,
`username` varchar(20) NOT NULL,
`email` varchar(60) NOT NULL,
`password` varchar(50) NOT NULL,
`key_control` varchar(50) NOT NULL,
`ver` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE profile (
`id` INT, users_id INT,
INDEX par_ind (users_id),
FOREIGN KEY (users_id) REFERENCES users(id) ON DELETE CASCADE,
`opz1` varchar(100) NOT NULL,
`opz2` int(1) NOT NULL DEFAULT '0',
`opz3` int(1) NOT NULL DEFAULT '0',
`opz4` int(1) NOT NULL DEFAULT '0',
`opz5` int(1) NOT NULL DEFAULT '0',
`opz6` int(1) NOT NULL DEFAULT '0',
`opz7` int(1) NOT NULL DEFAULT '0',
`opz8` int(1) NOT NULL DEFAULT '0',
`opz9` int(1) NOT NULL DEFAULT '0',
`opz10` int(1) NOT NULL DEFAULT '0',
`opz11` int(1) NOT NULL DEFAULT '0',
`opz12` int(1) NOT NULL DEFAULT '0',
`opz13` int(1) NOT NULL DEFAULT '0',
`opz14` int(1) NOT NULL DEFAULT '0',
`opz15` int(1) NOT NULL DEFAULT '0',
`opz16` int(1) NOT NULL DEFAULT '0',
`opz17` int(1) NOT NULL DEFAULT '0',
`opz18` int(1) NOT NULL DEFAULT '0',
`opz19` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Quando cancello un record nella prima tabella mi cancella anche i dati di riferimento della seconda.
L'unico problema è che nella seconda tabella non mi popola i campi id e user_id!!!
Rimangono null
Sapreste dirmi dove ho cannato?
graziegraziegrazie!!

Rispondi quotando