Jump to content

Recommended Posts

I am writing a script to export a table to excel for a client

 

They have a column 'more_info' that they have brilliantly included html and javascript in. This is breaking the file when it's exported. Works fine until it hits the html and then the

<br>

screws up the rest of the file.

 

I tried strip_tags but got the same result

 

while($row_DetailRS1 = mysql_fetch_array($DetailRS1)){

		for($i=0; $i< count($row_DetailRS1); $i++){
			echo strip_tags($row_DetailRS1[$i]);

			if($i == count($row_DetailRS1)){

				echo "\r";
			}
			else {echo "\t";}
		}

 

I suspect strip_tags won't work on an array?

 

Ideas to fix this besides telling the client to get rid of the offending characters..?

Link to comment
https://forums.phpfreaks.com/topic/190401-html-and-other-code-in-table-problem/
Share on other sites

I did this:

 

$field = $row_DetailsRS1[$i];
$cleanfield = strip_tags($field);

 

The html is removed when I just print to the screen.

 

However the xls file is still borked. I emptied the field that was causing the problem and that row printed out fine.

 

Then I removed the column altogether(I am using a copy of the table to test with) and the xls file only had 1 row.

 

Very perplexing

OK. I've narrowed this down a bit I think. The problem being quotes in the html field.

 

I am exporting to CSV now and this is what I am getting on a screen dump:

 

http://,url"
Click here .
\"

 

The URL is getting broken up into separate fields.

 

The field in the table has both single and double quotes in it. How can I force those to be ignored?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.