1

I've looked through the various answers and none of them seem to be helping. I have a simple Insert Query that is working as expected. Nothing special

$user_account_query = mysqli_query($dbc,"
        INSERT INTO ACCOUNT (EMAIL, IS_OPEN)
        VALUES ('$email', 1)")
        or die ('Could not add user: '. mysql_error());

It is successfully inserting the record into my db

enter image description here

I also have an auto-incrementing column in the table being called enter image description here

However, when I call

$message = mysql_insert_id();

I get 0. Does anyone have any advice on how to get the correct ID?

John Conde
  • 217,595
  • 99
  • 455
  • 496
Alex
  • 542
  • 5
  • 24

2 Answers2

4

You're mixing up mysql and mysqli

$message = mysql_insert_id();

should be

$message = mysqli_insert_id($dbc);
John Conde
  • 217,595
  • 99
  • 455
  • 496
-1

Actually you are using myqli Libraray and then you are using other library function mysql_insert_id() you have to use mysqli_insert_id() that is why you getting 0