i am trying to run 3queries from a php script.
the first inserts details of a movie into my tblDVD table
the second gets the id of the record that was just entered
the third inserts a record into the tblDVDGenre table - (the id of the movie just entered and the id of the genre)
code looks liek this:
$conn=odbc_connect('DVDLobby','','');
$sql="INSERT INTO tblDVD(dvdID,UPC,Title,SortTitle,Rating,Released,RunningTime,Overview,FrontImageURL,MovieLocation,CollNumber,PurchaseDate,ChangerNumber,changerLocation)
VALUES('$myUPC','$myUPC','$myMovieTitle','$myMovieTitle','$myRating','$myReleaseDate','$myRunningTime','".$myDescription."','$myImageURL','Hard Drive',1,'$today',0,0)";
$rs=odbc_exec($conn,$sql);
$sql="Select Max(dvdNumber) As MaxId
From TblDVD";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
$maxID = odbc_result($rs,"MaxID");
$category = $_POST['category'];
$sql="INSERT INTO TblDVDGenre (dvdNumber, genreID)
VALUES($maxID, $category)";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{
exit("Error in SQL");
}
the first 2 queries are running - when i look in the database, a record was added to the tblDVD table and the value of maxID is successfully set in the second query
but the record is never added to the tblDVDGenre table.
what am i doing wrong?
if it matters, it is an access database.