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.