Hi! I've set up a script to pull information from a database and write it to a rich text file. However, whenever I load the page, I get a "Warning: Supplied argument is not a valid File-Handle resource" (it points to line 31). Anyway, could the problem be the characters in the "fputs" statements (the slashes or curly braces, etc) that are used to format the rtf file? My code is below.
Is it just that I'm going about this all wrong? The URL is:
http://cws.unc.edu/studentgovt/cabinet/admin/report_create.php
Thanks!
Tommy
tmann@email.unc.edu
========================================
<?php
include("db_connect.php");
//generate the headers to help a browser choose the correct application
header( "Content-type: application/msword" );
header( "Content-Disposition: inline, filename=test2.rtf");
$sql = "SELECT users.user, reports.report FROM users, reports WHERE users.user_ID = reports.user_ID AND (week >= '$monday'
AND week <= '$today')";
$mysql_result = mysql_query($sql,$connection);
$num_rows = mysql_num_rows($mysql_result);
$filename = "files/test2.rtf";
$filepointer = fopen ( $filename, "a+" );
while ($row=mysql_fetch_array($mysql_result)) {
$user=$row['user'];
$report=$row['report'];
fput($filepointer, "\par");
fput($filepointer, "\par }\pard \s15\ql\li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
{\b\fs24\ul $user - $chair$co_chair1 $vice_chair$co_chair2$");
fput($filepointer, "\par }{\fs24 $report");
}
mysql_close($connection);
?>