kann nicht mysqli_insert_id Arbeit .. Die ID ist AUTO_INCREMENT
aber immer noch nicht funktioniert.mysqli_insert_id gibt 0 konstant
$query = "INSERT INTO categoriasdivisiones (titulo, orden, descripcion, id_familiadivisiones) VALUES ('$titulo','$orden', '$descripcion', '$id_familia');";
mysqli_query($base, $query);
$ultimo_id = mysqli_insert_id($base);
Hier nenne ich die Datenbank:
include('../../../php/config.php');
die Strecke in Ordnung ist.
Ich kenne das Problem in dem Code wird die insert_id Funktion, weil ich ein Bild haben, wo ich diesen Pfad verwenden:
move_uploaded_file($foto['tmp_name'], '../../../imagenes/categoriadivisiones/catdivisiones_'.$ultimo_id.'.'.$extensionfoto.'');
Und das Bild gespeichert wird als = catdivisiones_0.png
Sie Hoffnung kann mir helfen.
CREATE TABLE `categoriasdivisiones` (
`id` int(11) NOT NULL,
`titulo` text NOT NULL,
`descripcion` text NOT NULL,
`imagen` text NOT NULL,
`orden` text NOT NULL,
`id_familiadivisiones` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `categoriasdivisiones`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
[Little Bobby] (http://bobby-tables.com/) sagt *** [Ihr Skript ist für SQL Injection Attacks gefährdet.] (Http://stackoverflow.com/questions/60174/how-can-i-prevent -sql-injection-in-php *** Erfahren Sie mehr über [vorbereitete] (http://en.wikipedia.org/wiki/Prepared_statement) Anweisungen für [MySQLi] (http://php.net/manual/en/ mysqli.quickstart.prepared-statements.php). Sogar [die Zeichenfolge zu entkommen] (http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) ist nicht sicher! –
Die Funktion 'mysqli_insert_id()' gibt die ID (generiert mit 'AUTO_INCREMENT') zurück, die in der letzten Abfrage verwendet wurde. Verwenden Sie Autoinkrement? –
Ja, ich bin, "Die ID ist A_I, funktioniert aber immer noch nicht." –