Tab character into text file question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Tab character into text file question

Post by JPlush76 »

I need to output a select statement to a text file..

my fields are supposed to be separated with tabs IE field[tab]field2[tab]field3[tab][newline]

here is how I'm doing my line

Code: Select all

<?php

$content .= $program_id."\t".$orders_id."\t".$order_date."\t\n";

?>
I throw all that data into a text field in a database table... then I select * from that table into an outfile.

When I look at the data in the database it looks great field THEN TAB field2 THEN TAB but when I look at the text file it creates its adding the slashes

field\[TAB]field2\[TAB]

any thoughts on why that could be happening?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

I have no clue why it's doing that... :? just run strip slashes on the string after.. but you probably knew that..
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

well its a straight mysql command so there's no stripping slashes on the outfile command :(
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

oh.. i see what u mean now, that's wierd :?
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

have you tried single quotes instead of doubles?? just a thought
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

ehhh looks like it was stupid escaping quotes around the tab character

SELECT * FROM dump INTO OUTFILE 'dump/data.file' FIELDS TERMINATED BY \"/\t\" LINES TERMINATED BY \"/\n\""

seems to work dandy now
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

hehe :lol:
Post Reply