Hi there,
I'm pretty new to MySQL and PHP.
I'm trying to build a database but something goes wrong.
After inserting a single record into a table (using a .php page) there are 3 entries in my table:
One with the bandname I wanted to insert and 2 others with just an ID and no bandname
Here's what I'm trying to do:
<?PHP
@mysql_connect("bla bla", "blabla", "blabla") or die ("can't connect");
mysql_select_db("Appl");
$query = "INSERT INTO Artiesten (Artiest) VALUES ('$bandnaam')";
$result = mysql_query($query) or die ("Band not inserted");
$latest_id = mysql_insert_id()or die ("Unable to find ID");
$latest_id = mysql_insert_id()or die ("id niet kunnen vinden");
$query2 = "INSERT INTO Titels (cdtitel,artiestid) VALUES ('$cdtitel','$latest_id')";
$result2 = mysql_query($query2) or die ("Titel not Inserted");
The Artiesten table is just (ID, Artiest)
The titels table looks like (ID, cdtitel,artiestid)
Why are there too much records created?
Please also reply to: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
Thanks !
I'm pretty new to MySQL and PHP.
I'm trying to build a database but something goes wrong.
After inserting a single record into a table (using a .php page) there are 3 entries in my table:
One with the bandname I wanted to insert and 2 others with just an ID and no bandname
Here's what I'm trying to do:
<?PHP
@mysql_connect("bla bla", "blabla", "blabla") or die ("can't connect");
mysql_select_db("Appl");
$query = "INSERT INTO Artiesten (Artiest) VALUES ('$bandnaam')";
$result = mysql_query($query) or die ("Band not inserted");
$latest_id = mysql_insert_id()or die ("Unable to find ID");
$latest_id = mysql_insert_id()or die ("id niet kunnen vinden");
$query2 = "INSERT INTO Titels (cdtitel,artiestid) VALUES ('$cdtitel','$latest_id')";
$result2 = mysql_query($query2) or die ("Titel not Inserted");
The Artiesten table is just (ID, Artiest)
The titels table looks like (ID, cdtitel,artiestid)
Why are there too much records created?
Please also reply to: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
Thanks !