Hi Everyone, I am trying to get to grips with php prepared statements, I am getting there slowly...
My question is how do I ge the last insert ID from the following.
if ($stmt = $mysqli->prepare("INSERT INTO tbl_name (value1, value2, value3, value4, value5, value6, value7)
values (?, ?, ?, ?, ?, ?, ?)")) {
// Bind paramaters
$stmt->bind_param('sssssss', $var1, $var2, $var3, $var4, $var5, $var6, $var7);
//form values
$var1 = "$var1"; //1
$var2 = "$var2"; //2
$var3 = "$var3"; //3
$var4 = "$var4"; //4
$var5 = "$var5"; //5
$var6 = "$var6"; //6
$var7 = "$var7"; //7
// # Execute the prepared Statement
$stmt->execute();
// # get the last insert id
$newId = $mysqli->lastInsertId();
Each time I try this, either with $stmt or $mysqli I get the following error
"Call to undefined method mysqli::lastInsertId()"