Im trying to get id of the last inserted id on a table called authors to use it in another insert to a table called mail.
As you can see this is inserting a new author in table authors, and right after the insertion it must insert a welcome message to the new author in table mail.
Im using mysql_insert_id() but its not working. Nothing is saved to database and no errors occurs.
I know i should not use mysql_query but its ok, thats not the point here, just ignore this please.
if(!isset($row[email])){ $sql = "INSERT INTO authors VALUES (NULL, 0, '".$email."', '".$username."', NULL, '".$first."', '".$fullname."', '".$first."', NULL, NULL, NULL, NULL,'http://www.gravatar.com/avatar/".md5(strtolower(trim($email)))."', 0);"; mysql_query($sql); $sqlmsg = "INSERT INTO mail VALUES (NULL, 1, mysql_insert_id(), 'Welcome', Hello! Welcome to the website!', 'unread', NOW, 0, 0)"; mysql_query($sqlmsg); } Why nothing happens when a new author is inserted?
Thank you.