Hallo zusammen,
leider funktioniert die Funktion mysql_insert_id() bei mir kein Stück.
Hier mal der Code:
<?php
$table_name = $_POST['table_name'];
require("mysql.connect.php");
global $link;
global $lastid;
echo "letzte id: " . $lastid;
If ($table_name == 'table_items') {
$barcode = $_POST['barcode'];
$title = $_POST['title'];
$type = $_POST['type'];
$genre = $_POST['genre'];
$format = $_POST['format'];
$language = $_POST['language'];
$fsk = $_POST['fsk'];
$publicationdate = $_POST['publicationdate'];
$lenght = $_POST['lenght'];
$description = $_POST['description'];
mysql_query("INSERT INTO items (itemsid, barcode, title, type, genre, format, language, fsk, publicationdate, lenght, description) VALUES('NULL', '$barcode', '$title', '$type', '$genre', '$format', '$language', '$fsk', '$publicationdate', '$lenght', '$description')") or die(mysql_error());
$lastid = mysql_insert_id();
$link = "details_" . $type;
}
Elseif ($table_name == 'table_music'){
$albumtitle = $_POST['albumtitle'];
$songnumber = $_POST['songnumber'];
$version = $_POST['version'];
$bitrate = $_POST['bitrate'];
$link = "artists";
mysql_query("INSERT INTO music (musicid, albumtitle, songnumber, version, bitrate) VALUES('$lastid', '$albumtitle','$songnumber','$version', '$bitrate')") or die(mysql_error());
}
header("LOCATION: $link.html");
// $sql = "SELECT * FROM `items`";
//
// require("mysql.ausgabe.php");
?>
Ist ja eigentlich nicht all zu schwer... aber die Variable $lastid bleibt immer leer....
Vielen Dank!
MfG
Benni
leider funktioniert die Funktion mysql_insert_id() bei mir kein Stück.
Hier mal der Code:
<?php
$table_name = $_POST['table_name'];
require("mysql.connect.php");
global $link;
global $lastid;
echo "letzte id: " . $lastid;
If ($table_name == 'table_items') {
$barcode = $_POST['barcode'];
$title = $_POST['title'];
$type = $_POST['type'];
$genre = $_POST['genre'];
$format = $_POST['format'];
$language = $_POST['language'];
$fsk = $_POST['fsk'];
$publicationdate = $_POST['publicationdate'];
$lenght = $_POST['lenght'];
$description = $_POST['description'];
mysql_query("INSERT INTO items (itemsid, barcode, title, type, genre, format, language, fsk, publicationdate, lenght, description) VALUES('NULL', '$barcode', '$title', '$type', '$genre', '$format', '$language', '$fsk', '$publicationdate', '$lenght', '$description')") or die(mysql_error());
$lastid = mysql_insert_id();
$link = "details_" . $type;
}
Elseif ($table_name == 'table_music'){
$albumtitle = $_POST['albumtitle'];
$songnumber = $_POST['songnumber'];
$version = $_POST['version'];
$bitrate = $_POST['bitrate'];
$link = "artists";
mysql_query("INSERT INTO music (musicid, albumtitle, songnumber, version, bitrate) VALUES('$lastid', '$albumtitle','$songnumber','$version', '$bitrate')") or die(mysql_error());
}
header("LOCATION: $link.html");
// $sql = "SELECT * FROM `items`";
//
// require("mysql.ausgabe.php");
?>
Ist ja eigentlich nicht all zu schwer... aber die Variable $lastid bleibt immer leer....
Vielen Dank!
MfG
Benni
Kommentar