I'm having some trouble outputting to a file. using the PHP manual as my guide, I worked up this code to use ob_start, ob_end_flush, etc. My problem is explained below the code.
<?php
$mypath = getcwd();
$getfile="page.php?table=intro&id=1";
//$getfile="static.php";
$getpath="$mypath/$getfile";
$outpath="page1.htm";
ob_start();
require ("$getfile");
$html = ob_get_contents();
ob_end_clean();
// write output to file
$fp = fopen("test/".$outpath, "w");
If ($fp) {
print ("wahoo! we just compiled ".$getfile."!");
}
fwrite($fp, $html);
fclose($fp);
ob_end_flush();
?>
If I send static.php (commented out), a simple php page that uses includes and a few other variables for formatting, the file is created just fine. If I send page.php?table=intro&id=1, a page that queries a postgres db and places the data from a single record in the middle of the page, I get an ugly error message like this:
Fatal error: Failed opening required 'page.php?table=intro&id=1' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/compile.php on line 9
Both files use includes from the same directory and are referenced the same. The only thing I can think of is that the db query is causing this. Advice?
thanks,
/mark