I have a PHP script and when I run it it inserts a string into a field called patch_name in a table called patches. The table has an auto incrementing ID called PATCH_ID
Everything works fine and is inserted.The PATCH_ID increments as expected.
However mysql_insert_id() echos out 0
Code
mysqli_query($con,"INSERT INTO patches (patch_name)
VALUES ('hi')");
$insertID = mysql_insert_id();
echo $insertID;
You are using mysqli_* so better use
mysqli_insert_id($con);
Hope it helps.
Please have a look at mysqli_insert_id.
That's easy: Do use the functions of one extension only, do not mix them.
You use MYSQLI for your query, and MYSQL for the inserted id - this will never work.