Daniel Israel wrote: > > > > On Jul 9, 2008, at 9:31 AM, Wade Smart wrote: > > > Wade Smart wrote: > >> James Keeline wrote: > >> > >>> INSERT INTO players SET fname='Bill', lname='Smith', join=NOW(); > >>> INSERT INTO registration SET uid=LAST_INSERT_ID, team='Reds', > >>> updated=NOW(); > >>> > >>> What I'm trying to illustrate here is that the second query uses > >>> LAST_INSERT_ID > >>> to hold the primary key value from the players table. More > >>> details on this in > >>> the MySQL docs: > >>> > >>> http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html > <http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html> > >>> James > >>> > >> > >> 20080706 1206 GMT-6 > >> I insert them into players. > >> Then I write: > >> INSERT INTO registration SET uid=LAST_INSERT_ID, VALUES(NOW(); > >> 'Fall2008'); > >> > >> I have never really understood the joins. Since I do not have a > >> date on my > >> players table, do I need one for the join=NOW(); or is this used > >> outside of the > >> table structure? > >> > >> Wade > > > > 20080709 1130 GMT-6 > > > > Well, I dont have it straight yet. > > > > After I insert into the players table I do this: > > > > if(mysql_affected_rows() == 1) { $query = 'INSERT reg_date, > > player_id, > > INTO registration VALUES(NOW(),". uid=LAST_INSERT_ID)'; > > > > > > Apparently that is not how it is used. > > How about trying: > > $query = 'INSERT reg_date, player_id, INTO registration VALUES(NOW(), > LAST_INSERT_ID())'; >
I haven't been paying attention to what you guys are trying to do but the correct syntax of that query would be: $query = 'INSERT INTO registration (reg_date, player_id) VALUES (NOW(), LAST_INSERT_ID())'; -Billy P.
