I am new to PHP and MySQL. I am getting the last ID used for an insert using insert_id. How do I (or can I?) store that value to a variable so I can continue to use it (to persist a session, to look up other data, etc.)? Here is my code:
$result = $conn->query("insert into user (passwd, email) values (sha1('$password'), '$email')");
echo 'ID of new inserted row is : '.$conn->insert_id; //this works to print out the last ID
$lastid = $conn->insert_id(); //my code errors here
echo $lastid;
$conn is my mysqli connection. Everything works except the last 2 lines. What am I doing wrong? I have tried the documentation, google, etc.
Thanks so much in advance!!!