我有以下代码。应该返回表的最后一行的 mysqli_insert_id()(在本例中为“$last_row”)总是返回 0。为什么会这样?
<?php
include 'connect-db.php';
$last_row = mysqli_insert_id($connection);
if ($content != '') {
$sql = "INSERT INTO myCity VALUES (NULL, 'Stuttgart', 'DEU', 'Stuttgart', 617000)";
if (!mysqli_query($connection, $sql)) {
die('Error: ' . mysqli_error($connection));
}
echo $last_row;
mysqli_close($connection);
}