In MySQL you can define, that a column contains an auto increment value. This means that, whenever there is an insert command, the ID (this is what the auto increment value is usually used for) will be increment by a pre-defined value.
Now, when you use ad hoc queries (simple string concatenating like “Insert into user values (‘ ” . $username . ” ‘ , ‘ ” . $first_name . ” ‘) “” ); you can invoke the function mysql_insert_id to get the increment value of this insert operation.
But when you use Prepared Statements (Man Page) instead, you have to use the mysqli_insert_id function instead! When using this function, you also have to pass the connection object to the function.
If you try to use the mysql_insert_id function, you will receive an error message saying:
mysql_insert_id() function.mysql-insert-id: A link to the server could not be established in dbOps.php.
Also passing the connection object to function mysql_insert_id() will not help. The error will say then some like mysql_insert_id(): supplied argument is not a valid MySQL-Link resource in dbOps.php.