Ian Ian - 1 year ago 93
PHP Question

insert_id not getting the current id

I have been reading the other quotes regarding this and haven't found an answer. I'm trying to return the record id with


$user = $db->query("
INSERT INTO users(user_name,user_email,user_password,user_salt,
VALUES ('".$userName."',
#Add the user
$newID = $user->insert_id;

If any one has any idea that would be great.

Answer Source

Solution in your case will be using $newID = $db->insert_id; instead of $newID = $user->insert_id;.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download