Another approach you can try is the following:
1) create a folder somewhere in your server tree that will contain the source files
2) read the db query into a file (extension is not an issue but *.txt is a good example)
3) call the following:
<?
show_source("path/to/folder/name_of_file.txt");
?>
Since the file will be sourced to the hard dive you now have two options:
1) create a script which will periodically delete all *.txt files from that folder
2) modify your db query script to check if the text file already exists.
For option 2, you could try adding a field (named "Written" for example) to the database which will accept either 0 or 1 as a value. Modify the script so that, once the file is written to the hard drive, the value of Wirtten changes from 0 to 1.
for example:
<?
// code to query db and return it to $result_array
if ($result_array['Written'] == 1)
{
show_source("path/to/folder/name_of_file.txt");
}
else
{
$sql("query line to update Written from 0 to 1");
mysql_query($sql) or die("Unable to update db");
// code to write db query to file
show_source("path/to/folder/name_of_file.txt");
}
?>
This will of course give the benefit of not having to re-write the file every so often. Unfortunately, show_source() is not supported in the Win32 version of PHP 3.0.16 so you'll have to upgrade to PHP 4.0.x. If this isn't an option, try modifying the above to save the db query as a .phps file then redirrect the to client to that file. I wasn't unable to get the .phps to parse when I tried, hence the reason why I upgraded to PHP4.