<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: PHP and MySQL: Export a Query to a Tab Delimited File</title>
	<atom:link href="http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/feed/" rel="self" type="application/rss+xml" />
	<link>http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/</link>
	<description>new media strategies and other marketing gems</description>
	<pubDate>Thu, 08 Jan 2009 21:39:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Polyglot</title>
		<link>http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/comment-page-1/#comment-162426</link>
		<dc:creator>Polyglot</dc:creator>
		<pubDate>Sun, 29 Jun 2008 01:12:23 +0000</pubDate>
		<guid isPermaLink="false">http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/#comment-162426</guid>
		<description>Sure can.

Try something like this:

SELECT * from MyTableName INTO OUTFILE 'MyTableName_MySQL-TAB-DELIMITED-29JUN08.txt' FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';

If you want a double space (two empty lines) between record groups, just say "LINES TERMINATED BY '\n\n';" instead.

The "FIELDS TERMINATED BY '\n'" portion is what puts a newline after each record, instead of a tab.  A tab would be '\t' instead.  

Maranatha!</description>
		<content:encoded><![CDATA[<div class="KonaBody">Sure can.</p>
<p>Try something like this:</p>
<p>SELECT * from MyTableName INTO OUTFILE &#8216;MyTableName_MySQL-TAB-DELIMITED-29JUN08.txt&#8217; FIELDS TERMINATED BY &#8216;\n&#8217; LINES TERMINATED BY &#8216;\n&#8217;;</p>
<p>If you want a double space (two empty lines) between record groups, just say &#8220;LINES TERMINATED BY &#8216;\n\n&#8217;;&#8221; instead.</p>
<p>The &#8220;FIELDS TERMINATED BY &#8216;\n&#8217;&#8221; portion is what puts a newline after each record, instead of a tab.  A tab would be &#8216;\t&#8217; instead.  </p>
<p>Maranatha!</p></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: newbie@this</title>
		<link>http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/comment-page-1/#comment-150923</link>
		<dc:creator>newbie@this</dc:creator>
		<pubDate>Sun, 15 Jun 2008 16:49:52 +0000</pubDate>
		<guid isPermaLink="false">http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/#comment-150923</guid>
		<description>This works well.  However, I just get everything on one line separated by a space.  I am trying to modify it to print everything on a separate line like this:

Column1_name
Field1_value
Column2_name
Field1_value
Column3_name
Field1_value

Column1_name
Field2_value
Column2_name
Field2_value
Column3_name
Field2_value

For example:

Name
Mike
Location
Work
Number 
1

Name
Sue
Location
Home
Number
2

Name
John
Location
Travel
Number
10

and so on.  Can this script be modified to do it?
Thanks!</description>
		<content:encoded><![CDATA[<div class="KonaBody">This works well.  However, I just get everything on one line separated by a space.  I am trying to modify it to print everything on a separate line like this:</p>
<p>Column1_name<br />
Field1_value<br />
Column2_name<br />
Field1_value<br />
Column3_name<br />
Field1_value</p>
<p>Column1_name<br />
Field2_value<br />
Column2_name<br />
Field2_value<br />
Column3_name<br />
Field2_value</p>
<p>For example:</p>
<p>Name<br />
Mike<br />
Location<br />
Work<br />
Number<br />
1</p>
<p>Name<br />
Sue<br />
Location<br />
Home<br />
Number<br />
2</p>
<p>Name<br />
John<br />
Location<br />
Travel<br />
Number<br />
10</p>
<p>and so on.  Can this script be modified to do it?<br />
Thanks!</p></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Richards</title>
		<link>http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/comment-page-1/#comment-66921</link>
		<dc:creator>Joe Richards</dc:creator>
		<pubDate>Thu, 22 Nov 2007 23:22:18 +0000</pubDate>
		<guid isPermaLink="false">http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/#comment-66921</guid>
		<description>I just lost more than 6 hours of my life trying to work out why Internet Explorer 6/7 was applying filetype 'html' and and not accepting my custom filenames specified in the headers.. and also not allowing files to be saved.. when attempting to have users download text files created in a similar way to above.

I was using HTTPS and IE does not cache these files.

I found the solution on a comment by Brandon K at http://uk.php.net/header.

He says:

-----
I just lost six hours of my life trying to use the following method to send a PDF file via PHP to Internet Explorer 6:

 

When using SSL, Internet Explorer will prompt with the Open / Save dialog, but then says "The file is currently unavailable or cannot be found.  Please try again later."  After much searching I became aware of the following MSKB Article titled "Internet Explorer file downloads over SSL do not work with the cache control headers" (KBID: 323308)

PHP.INI by default uses a setting: session.cache_limiter = nocache which modifies Content-Cache and Pragma headers to include "nocache" options.  You can eliminate the IE error by changing "nocache" to "public" or "private" in PHP.INI -- This will change the Content-Cache header as well as completely remove the Pragma header.  If you cannot or do not want to modify PHP.INI for a site-wide fix, you can send the following two headers to overwrite defaults:



You will still need to set the content headers as listed above for this to work.  Please note this problem ONLY effects Internet Explorer, while Firefox does not exhibit this flawed behavior.
----

Well.. at least he only lost 6 hours...</description>
		<content:encoded><![CDATA[<div class="KonaBody">I just lost more than 6 hours of my life trying to work out why Internet Explorer 6/7 was applying filetype &#8216;html&#8217; and and not accepting my custom filenames specified in the headers.. and also not allowing files to be saved.. when attempting to have users download text files created in a similar way to above.</p>
<p>I was using HTTPS and IE does not cache these files.</p>
<p>I found the solution on a comment by Brandon K at <a href="http://uk.php.net/header" rel="nofollow">http://uk.php.net/header</a>.</p>
<p>He says:</p>
<p>&#8212;&#8211;<br />
I just lost six hours of my life trying to use the following method to send a PDF file via PHP to Internet Explorer 6:</p>
<p>When using SSL, Internet Explorer will prompt with the Open / Save dialog, but then says &#8220;The file is currently unavailable or cannot be found.  Please try again later.&#8221;  After much searching I became aware of the following MSKB Article titled &#8220;Internet Explorer file downloads over SSL do not work with the cache control headers&#8221; (KBID: 323308)</p>
<p>PHP.INI by default uses a setting: session.cache_limiter = nocache which modifies Content-Cache and Pragma headers to include &#8220;nocache&#8221; options.  You can eliminate the IE error by changing &#8220;nocache&#8221; to &#8220;public&#8221; or &#8220;private&#8221; in PHP.INI &#8212; This will change the Content-Cache header as well as completely remove the Pragma header.  If you cannot or do not want to modify PHP.INI for a site-wide fix, you can send the following two headers to overwrite defaults:</p>
<p>You will still need to set the content headers as listed above for this to work.  Please note this problem ONLY effects Internet Explorer, while Firefox does not exhibit this flawed behavior.<br />
&#8212;-</p>
<p>Well.. at least he only lost 6 hours&#8230;</p></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: K</title>
		<link>http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/comment-page-1/#comment-59920</link>
		<dc:creator>K</dc:creator>
		<pubDate>Fri, 12 Oct 2007 17:12:14 +0000</pubDate>
		<guid isPermaLink="false">http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/#comment-59920</guid>
		<description>But you could just run the query to a file, and just redirect the browser to the generated file, or use PHP's "readfile" if all else fails?

You won't be able to do that if the mysql server doesn't have access to the filesystem of course...</description>
		<content:encoded><![CDATA[<div class="KonaBody">But you could just run the query to a file, and just redirect the browser to the generated file, or use PHP&#8217;s &#8220;readfile&#8221; if all else fails?</p>
<p>You won&#8217;t be able to do that if the mysql server doesn&#8217;t have access to the filesystem of course&#8230;</p></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Douglas Karr</title>
		<link>http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/comment-page-1/#comment-59679</link>
		<dc:creator>Douglas Karr</dc:creator>
		<pubDate>Tue, 09 Oct 2007 20:04:10 +0000</pubDate>
		<guid isPermaLink="false">http://marketingtechblog.com/2007/10/08/php-mysql-export-tab-delimited/#comment-59679</guid>
		<description>I'll be building that one in PHP within the week, Noah!  Bloid is a MySQL Monster!  Thanks for all the input!!!</description>
		<content:encoded><![CDATA[<div class="KonaBody">I&#8217;ll be building that one in PHP within the week, Noah!  Bloid is a MySQL Monster!  Thanks for all the input!!!</div>
]]></content:encoded>
	</item>
</channel>
</rss>
