I have ".html" file and inside it I run php code. The php code should open ".ini" file.
".ini" file:
blast+: blast+\bin
blastn: test_na_db => Nucleotide test database
blastp: test_aa_db => Protein test database
blastx: test_aa_db => Protein test database
tblastn: test_na_db => Nucleotide test database
tblastx: test_na_db => Nucleotide test database
".html" file:
<td valign=top>   Database(s)</td>
<td>
<?php
$fp = fopen ("./filename.ini", "r");
if(!$fp) {
    echo "<p><strong> Error: Couldn't open file filename.ini </strong></p></body></html>";
    exit;
}
while(!feof($fp)) {
    $blastdbstring = rtrim(fgets($fp));
    if (!$blastdbstring) {
        continue;
    }
    if (!preg_match("/^\s*#/", $blastdbstring)) {
        $blastdbArray = preg_split('/:/', $blastdbstring);  
        $blastProgram = $blastdbArray[0];
        $dbString = $blastdbArray[1];
        if ($blastProgram == "blast+") {
            echo "<input type='hidden' name= 'blastpath' value='$dbString'>";
        }else {
            if (preg_match("/^\s*(.*?)\s*$/", $blastProgram, $match)) {
                $blastProgram = $match[1];
            }
            if (preg_match("/^\s*(.*?)(\s*|\s*,\s*)$/", $dbString, $match)) {
                $dbString = $match[1];
            }
            $dbString = preg_replace("/\s*=>\s*/", "=>", $dbString);
            if (preg_match("/,/", $dbString, $match)) {
                $dbString = preg_replace("/\s*,\s*/", ",", $dbString);
            }       
            echo "<input id='$blastProgram' type='hidden' name='blastdb[]' value='$dbString'>";
        }
    }   
}
fclose($fp);
?>
<select id="dbList" size=4 multiple="multiple" name ="patientIDarray[]">
<script type="text/javascript">
    here call js function that create options depend on the selection of previous question
</script>
</select>
</td>
Each time I got this error message: Couldn't open file filename.ini!!!!
".html" file and ".ini" file are in the same directory.
I have full control on that ".ini" file
Any suggestions?
You probably want to use parse_ini_file
// Parse without sections
$ini_array = parse_ini_file("sample.ini");
print_r($ini_array);
// Parse with sections
$ini_array = parse_ini_file("sample.ini", true);
print_r($ini_array);
http://php.net/manual/en/function.parse-ini-file.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With