I need to retrieve the auto increment field from my database table. I tried the following but $id
is always just empty.
The insert works too.
My table is as follows:
id
int(9) NOT NULL auto_increment,
and id
is set as primary
What am I doing wrong? $conn = mysql_connect($host,$username,$password); mysql_select_db($database, $conn) or die( "Unable to select database"); include "update_activity.php"; updateActivity("logged in", "On Break");
$date = date("m/d/y"); $starttime = time();
$sesh = $_SESSION['fname']." ".$_SESSION['lname'];
$q = "INSERT INTO `breaks` (date, starttime, user) VALUES ('".$date."', '".$starttime."', '".$sesh."')";
$query = mysql_query($q, $conn);
$id = mysql_insert_id($conn);
echo var_dump($id); exit;
edited to show my more recent attempts