miltonos Posted March 1, 2007 Share Posted March 1, 2007 I am attempting to write data out to a text file from a MySql database. The data in the db field is clean with no html codes (I can verify this). When I retrieve the data and then write it out to a text file in a directory under 'Apache/htdocs' all my single and double quotes have been converted to HTML Codes. Here is the code I am using to write to the directory: $bs = fopen(".//downloads//" .$fileName, "w"); fwrite($bs, $licenseFile, strlen($licenseFile)); fclose($bs); I have even used str_replace() immediately before the fopen() call to search the $licenseFile for HTML codes and replace them with the proper characters but to no avail. Because this is a license file I cannot have errant characters reproduced in it. Thank you for any insight into what I am doing wrong. Milton S. Link to comment https://forums.phpfreaks.com/topic/40725-unwanted-html-codes-in-text-file/ Share on other sites More sharing options...
genericnumber1 Posted March 1, 2007 Share Posted March 1, 2007 maybe try html_entity_decode() before writing to the file? Link to comment https://forums.phpfreaks.com/topic/40725-unwanted-html-codes-in-text-file/#findComment-197169 Share on other sites More sharing options...
simcoweb Posted March 1, 2007 Share Posted March 1, 2007 So it's converting the quotes to their equivalent HTML code characters when you write the file? Is that what i'm understanding? Link to comment https://forums.phpfreaks.com/topic/40725-unwanted-html-codes-in-text-file/#findComment-197170 Share on other sites More sharing options...
miltonos Posted March 1, 2007 Author Share Posted March 1, 2007 maybe try html_entity_decode() before writing to the file? simcoweb, Thank you for the reply. htm_entity_decode() did work. I used it as: $bs = fopen(".//downloads//" .$fileName, "w"); fwrite($bs, html_entity_decode($licenseFile,ENT_QUOTES), strlen($licenseFile)); fclose($bs); I would really like to know how the html codes are getting into my string? Is there a php.ini setting that should be configured differently? Again thank you for the response. Milton S. Link to comment https://forums.phpfreaks.com/topic/40725-unwanted-html-codes-in-text-file/#findComment-197267 Share on other sites More sharing options...
miltonos Posted March 1, 2007 Author Share Posted March 1, 2007 Sorry, I got the names backwards. Thanks to genericnumber1 for a solution, and to simcoweb, yes somewhere after I get the string out of the database the single and double quotes are being converted to html codes. Milton S. Link to comment https://forums.phpfreaks.com/topic/40725-unwanted-html-codes-in-text-file/#findComment-197276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.