Page 1 of 1

Last incremented value

Posted: Tue May 27, 2003 4:16 am
by vipul73
I am getting email address of a user from a feedback form and wish to generate a visitor number from that. I have tried inserting the email in a database and would like to get the last incremented value how do i get the same.

Code: Select all

<?php 
$email = $_POST["email"];
$db = mysql_connect("localhost", "root");
mysql_select_db("visitor",$db);
$sql = "INSERT INTO invoice (email) VALUES ('$email')";
$result = mysql_query($sql);
mysql_insert_id();
echo "Thank you! Information entered.\n";
?>

Posted: Tue May 27, 2003 4:40 am
by twigletmac
You've already got this:

Code: Select all

mysql_insert_id();
try setting it to a variable:

Code: Select all

$last_id = mysql_insert_id();
Mac

Posted: Tue May 27, 2003 9:13 am
by vipul73
:) Thanks it is working perfectly now