Reputation: 25
I have been reading the other quotes regarding this and haven't found an answer. I'm trying to return the record id with insert_id
:
$user = $db->query("
INSERT INTO users(user_name,user_email,user_password,user_salt,
user_vMake,user_vModel,user_dateJoined,user_code)
VALUES ('".$userName."',
'".$userEmail."',
'".$hashedPassword."',
'".$salt."',
'".$userVMake."',
'".$userVModel."',
'".$userDateJoined."',
'".$randomCode."')
");
#Add the user
$newID = $user->insert_id;
If any one has any idea that would be great.
Upvotes: 0
Views: 1694
Reputation: 76583
$db
is your database object, $user
holds the return value of the query function. insert_id
is a member of $db
and is not a member of $user
. So instead of:
$user->insert_id
use
$db->insert_id
Upvotes: 3
Reputation: 7739
Solution in your case will be using $newID = $db->insert_id;
instead of $newID = $user->insert_id;
.
Upvotes: 1