$ mysqli-insert_id没有正确递增

I am trying to use $mysqli->insert_id to rename a file so my program can create more than one file. Instead it just creates one file with an id of 0 and each time it overwrites that file instead of creating a new one. I am wondering if I need to increment $mysli->insert_id or something.

But basically I want each file to be named the 'job_id'.fasta. Right now they all are 0.fasta.

I am confused because when I use mysqli->insert_id for my insert statement it correctly assigns job_ids to each new job. So when I SELECT * FROM Job I get a huge list of all the jobs 1-100. I want the files that are created from a job to be called the job_id instead of just 0.

Here is the code that I have.

<?php
if(isset($_POST['submit'])){
//      echo "submit1";
            //declare variables to what the user defines them as

            $db = $_POST['database'];
            $evalue = $_POST['evalue'];
            $sequence = $_POST['BlastSearch'];
            $hits = $_POST['hits'];


            //insert the values into the database



            //create a new .fasta file and put the sequence the user wants to search for in that file
            $file = 'uploads/'.$mysqli->insert_id.'.fasta';
            $current = $_POST['BlastSearch'];
            file_put_contents($file, $current);

            //execute the BLAST Tool
            // Do this execute statement if the user inputs his own sequence. (Use new.fasta)


?>

So the insert_id increments for inserting an id into the database for job_id but it doesnt increment in my $file = 'uploads/'.$mysqli->id or my exec function.

I guess you missed the idea somewhere.

It is not clear what is your problem according to your code.

Let me explain why I can't understand your issue.

Here is transformed fragment of your code:

$mysqli->query("INSERT INTO `Job` (`uid`, `input`, `status`, `start_time`, `finish_time`) VALUES ('1', '" . $sequence . "', 'running' , NOW(), NOW())");
$insertedJobId = $mysqli->insert_id;
$mysqli->query("INSERT INTO `BLAST`(`db_name`, `evalue`, `job_id`) VALUES ('" . $db . "','" . $evalue . "', '".$insertedJobId."')") or die(mysqli_error($mysqli));
$insertedBlastId = $mysqli->insert_id; 

//execute the BLAST Tool
// Do this execute statement if the user inputs his own sequence. (Use new.fasta)

exec('/students/groups/cs4380sp15grp4/blast/blast-2.2.26/bin/blastall -p blastp -d db -i /students/groups/cs4380sp15grp4/public_html/home/uploads/'.$insertedBlastId.'.fasta -m'.$evalue.' -o outputSEQ -v'.$hits.' -b'.$hits);

So which insert_id id is not incremented? $insertedJobId or $insertedBlastId ?