Jump to content

[SOLVED] help with mysql_insert_id


rondog

Recommended Posts

I am trying to get the ID of a row I just inserted obviously. my id field is auto_increment. This is my code:

 

$userQuery = mysql_query("INSERT INTO $tableName (username,email,firstname,lastname,company,date_added,confirmation_key) VALUES ('$username','$email','$firstName','$lastName','$company','$date_added','$confKey')") or die(mysql_error());
$insertID = mysql_insert_id($userQuery);

$expiry_period = $results['expiry_period'];
$expirationDate = strtotime("+".$expiry_period." minutes");
$tokenQuery = mysql_query("UPDATE $tokenTable SET client_id = '$insertID', active = 'yes', expiry_date = '$expirationDate' WHERE token = '$password'") or die(mysql_error());

 

Basically I am inserting the user and I need to take the ID of that new user and put it in another table but I am getting the error: mysql_insert_id(): supplied argument is not a valid MySQL-Link resource

Link to comment
https://forums.phpfreaks.com/topic/181337-solved-help-with-mysql_insert_id/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.