Hi all, I am generating a word doc on page load, it saves fine, but when I open it in msword a dialog popsm up asking me which encoding i would like for my text. Can i build this into my script to pick the charset automatically? <?php $docOut .= "Search Results Export"; ?> <?php $docOut .= "\n"; ?> <?php $docOut .= "Exported: " . number_format($num_rows[0]) . " results."; ?> <?php $docOut .= "\n"; ?> <?php $docOut .= "By: " . $_SESSION['firstName'] . " " . $_SESSION['lastName']; ?> <?php $docOut .= "\n"; ?> <?php $docOut .= "Date:" . " " . $dateToday; ?> <?php $docOut .= "\n"; ?> <?php $docOut .= "\n"; ?> //THE ROWS OF DATA THAT GET LOOPED $docOut .= "\n"; $docOut .= "____________________________"; $docOut .= "\n"; $docOut .= "\n"; $docOut .= "Name: " . $row1['FirstName'] . " " . $row1['LastName']; $docOut .= "\n"; $docOut .= "Town: " . $row1['Town']; $docOut .= "\n"; $docOut .= "Date: " . $row1['DateStamp']; $docOut .= "\n"; $docOut .= "Category: " . $row1['Category']; $docOut .= "\n"; $docOut .= "\n"; $docOut .= "Curiosity: " . $row1['Curiosity']; $docOut .= "\n"; //// WRITING OF THE FILE $exportPathdoc = 'data/exports/search-results/search-results-' . $dateToday . '.doc'; $fdoc = fopen ($exportPathdoc,'w'); fputs($fdoc, $docOut); fclose($fdoc); please help :) PHP:
put this code inside your file in the top between head tags.. <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> PHP: if not working then try to add inside your outputted file like: $docOut .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; $docOut .= "Search Results Export"; .............................. .................... ............ the rest of your codes ....... PHP: