Hello,
I'm having trouble getting information on tables in mysql,
I can't retrieve the number next in line for a field set to auto_increment.
I'm using LAST_INSERT_ID() in this fashion...
$sth = $dbh->do(<<End_SQL) or print "Couldn't prepare statement: $DBI::errstr; stopped";
INSERT INTO table1 VALUES (NULL,'Field1')
End_SQL
$sth = $dbh->do(<<End_SQL) or print "Couldn't prepare statement: $DBI::errstr; stopped";
INSERT INTO table2 VALUES ('',LAST_INSERT_ID(),'field1')
End_SQL
But I can't seem to get the generated number for field one into a $variable.
I shouldn't have to add a new entry into the table just to get the next number should I?
I can barely get the number of records with:
$sth = $dbh->do(<<End_SQL) or print "Couldn't prepare statement: $DBI::errstr; stopped";
SELECT * FROM table
End_SQL
$rows=$sth;
I'm having difficulty getting very simple information from these tables and have read the docs up & down.
Can someone help me put the peices together?
Thank you,
Tony
I'm having trouble getting information on tables in mysql,
I can't retrieve the number next in line for a field set to auto_increment.
I'm using LAST_INSERT_ID() in this fashion...
$sth = $dbh->do(<<End_SQL) or print "Couldn't prepare statement: $DBI::errstr; stopped";
INSERT INTO table1 VALUES (NULL,'Field1')
End_SQL
$sth = $dbh->do(<<End_SQL) or print "Couldn't prepare statement: $DBI::errstr; stopped";
INSERT INTO table2 VALUES ('',LAST_INSERT_ID(),'field1')
End_SQL
But I can't seem to get the generated number for field one into a $variable.
I shouldn't have to add a new entry into the table just to get the next number should I?
I can barely get the number of records with:
$sth = $dbh->do(<<End_SQL) or print "Couldn't prepare statement: $DBI::errstr; stopped";
SELECT * FROM table
End_SQL
$rows=$sth;
I'm having difficulty getting very simple information from these tables and have read the docs up & down.
Can someone help me put the peices together?
Thank you,
Tony