Cannot get PHP to write to a file
<p>Below is a simple database class, well its part of a class, I stripped everything out except the parts related to my question.  </p>

<p>Basicly it will allow me to build a file with all the queries that were ran on a page load with the time they took, the order they are in, the total count, and then also the actual SQL that was ran.  It is very nice but I am having trouble.  I cannot get it to write to the file, you can see below that I print to screen the value of $sss which is the value that should be written to file.  In PHP I have error reporting set to show everything and I get no write errors or anything, it just doesn't write to the file, possibly I may have the file on the wrong folder but I am not sure.  </p>

<p>So what would be a good way to set a filepath to the log file and also to make it write?  IF it cannot find the file now, should I see some sort of error?  </p>

<pre><code>&lt;?PHP
class Database
{
    public $debug = true;
    public $query_count = 0;
    public $debug_file = "debug.sql";

    public function query($sql){
        //start timer stuff for debug logger
        list($usec, $sec) = explode(" ",microtime());
        $time_start  = ((float)$usec + (float)$sec);

        //run mysql query
        $result = mysql_query($sql);


        ///debug    
        list($usec, $sec) = explode(" ",microtime());
        $time_end  =  ((float)$usec + (float)$sec);
        $time = $time_end - $time_start;
        if($this-&gt;debug){
            $this-&gt;query_count ++;
            $f = fopen($this-&gt;debug_file, "a");
            $sss = "# ".$this-&gt;query_count."\n ".$time." sec \n\n".$sql."\n#-------------------------------------------------------------------------\n\n";

            // I print to screen just for test to see what should be wrriten to the file
            echo $sss;

            fputs($f, $sss, strlen($sss));
            fclose($f);
        }
        //end debug
    }
}
?&gt;
</code></pre>
