Jump to content

Unwanted HTML Codes in text file.


miltonos

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.