$db = mysqli_query($connect, "INSERT INTO `payments` (player_id, service, amount, time, status) VALUES ('$uid', '$method', '$insum', '$time', '0')"); echo mysqli_insert_id($db); A line with AUTO INCREMENT is added to the database, you need to get the latest ID. With the mysqli_insert_id () function, I get emptiness, no values. Yuzal Google did not find anything. Please help.