hi i have some 500-1000 word essays stored as data type 'text' in a mysql database. i'm using the following code to generate an ms word-compatible rtf document off the database
-------snip------- //generate the headers to help a browser choose the correct application header( "Content-type: application/msword" ); header( "Content-Disposition: inline, filename=test.rtf"); $date = date( "F d, Y" ); // open our template file $filename = "mjp_rtf.rtf"; $fp = fopen ( $filename, "r" ); //read our template into a variable $output = fread( $fp, filesize( $filename ) ); fclose ( $fp ); // replace the place holders in the template with our data $output = str_replace( "<<userid>>", $userid, $output ); $mjp_essay1=nl2br($mjp_essay1); $mjp_essay1 = str_replace( "<br />", "\par", $mjp_essay1 ); $output = str_replace( "<<mjp_essay1>>", $mjp_essay1, $output ); $mjp_essay2=nl2br($mjp_essay2); $mjp_essay2 = str_replace( "<br />", "\par", $mjp_essay2 ); $output = str_replace( "<<mjp_essay2>>", $mjp_essay2, $output ); // send the generated document to the browser echo $output; -------snip------- this generates an rtf with a single essay printed on it. works fine. i'd now like to integrate the above code into a while loop that fetches multiple essays from the mysql db, and prints them out sequentially in a single rtf document. the following code creates an rtf document with multiple essay questions off a while loop/query, the problem: there seems to be special ms word characters (for ex., words formatted with italics or apostrophes are displayed on the rtf page with extra, weird looking ascii characters). the code -------snip------- header( "Content-type: application/msword" ); header( "Content-Disposition: inline, filename=essays.rtf"); $date = date( "F d, Y" ); //open template file $filename= "mjp_rtf2.rtf"; $fp=fopen($filename, "r"); //read our template into a variable $output = fread( $fp, filesize( $filename ) ); fclose ( $fp ); $string = "\page"; //begin while loop to cycle through db while ($result=mysql_fetch_array($query)){ //Increment the line index by 1 $_GET['lineIndex']++; $_GET['rowcount']++; $userid=$result['userid']; if (!($conn = $new_admin_class->db_connect())) return false; $result2 = mysql_query( "select * from mjp_essay1 where userid =".$userid.""); $row2 = mysql_fetch_array($result2); //getting info from row in db $mjp_essay1[$_GET['rowcount']] = $row2['mjp_essay1']; $result2 = mysql_query( "select * from mjp_essay2 where userid =".$userid.""); $row2 = mysql_fetch_array($result2); //getting info from row in db $mjp_essay2[$_GET['rowcount']] = $row2['mjp_essay2']; // replace the place holders in the template with our data $mjp_essay1 = nl2br($mjp_essay1[$_GET['rowcount']]); $mjp_essay1 = str_replace( "<br />", " \par ", $mjp_essay1 ); $mjp_essay2 = nl2br($mjp_essay2[$_GET['rowcount']]); $mjp_essay2 = str_replace( "<br />", " \par ", $mjp_essay2 ); $string=$string." Application Data Form - Userid ".$userid."\par Essay 1 \par \par \par ".$mjp_essay1." \par \par \par Essay 2 \par \par \par ".$mjp_essay2."\page"; } $output=str_replace("<<start>>",$string, $output); // send the generated document to the browser echo $output; } -------snip------- is based on the first snippet of code. yet the weird ascii characters before special formatting and apostrophes appears only in the second snippet of code. am i missing something? any help would be appreciated. thanks redmond -- Redmond Militante Software Engineer / Medill School of Journalism FreeBSD 5.2.1-RELEASE-p1 #0: Wed Mar 3 08:20:55 CST 2004 i386 5:45PM up 5:45, 3 users, load averages: 0.20, 0.10, 0.15
pgp00000.pgp
Description: PGP signature