I do not know what happened in my code.? I'm trying to get the last insert id, is its echo 0? any idea?
public function __construct() { $this->mysqli = new mysqli(MYSQLI_SERVER, MYSQLI_USER, MYSQLI_PWD, MYSQLI_DBNAME) or die ('Error with connecting to the database!');; } public function insert_id(){ return $this->mysqli->insert_id; } $db->query("INSERT INTO user(f_name, l_name) VALUES('$f_name', '$l_name')); var_dump($db->insert_id()); // return 0?
source share