Can anyone see what is wrong with the code below? For some reason i can get it to return the id of the affected row..in fact it doesnt return anything but the query runs fine and the record is created in the db…
$stmt = $this->db->stmt_init();
if($stmt->prepare('INSERT INTO Assets(id,assetName,type, username, password, mail) VALUES (?,?,?,?,?,?)'))
{
$stmt->bind_param("isssss", $id, $assetName, $type, $username, $password, $mail);
$stmt->execute();
$stmt->close();
return $stmt->insert_id;
}
else
{
$stmt->close();
return "";
}
You are closing the statements before trying to get the insert id: