last_insert_id question
Posted: Fri Sep 20, 2002 11:42 am
basically what I'm trying to do is enter a customer into the database then register their user_id (which is the autoincrement id) as a session variable.
I've read through the mysql manual but they don't have much info on last_insert_id
anyone know what I'm doing wrong? when I echo the session variable its always 0
I've read through the mysql manual but they don't have much info on last_insert_id
anyone know what I'm doing wrong? when I echo the session variable its always 0
Code: Select all
<?php
// ENTER USER IN DATABASE
$result = query_db("INSERT INTO customers (cust_first,cust_last,cust_email) "
."VALUES ('".$_POSTї'f_first']."', '".$_POSTї'f_last']."','".$_POSTї'f_email']."')");
// REGISTER SESSION VARIABLES
$_SESSIONї'user_id'] = query_db("SELECT last_insert_id()");
?>