Ok, I don't know how its happening either but here is the entire breakdown:

MySQL field: longtext

Step(1) - Text File is created on unix machine, transferred via FTP to a
Windows machine.

Step(2) - Perl script reads in the file and parses it grabbing certain lines
and inserts them into the database like so:

@inv_data = $dbh->quote("@inv_data");
$dbh->do("INSERT INTO ads_ff VALUES (?,?,?,?,?,?,?,?,?,?,?)", undef,
$inv_no,$ord_no,$date.'!',$tp,'1',$cust_po_num,$cust_num,@inv_data,
"$mysql_date",$inv_tot,$file);  

All the values are derived from substr() commands and passed to the method
which executes the latter.

Brian

-----Original Message-----
From: Paul DuBois [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 27, 2003 12:40 PM
To: Brian Spindler; 'Sterin, Ilya (I.)'; [EMAIL PROTECTED]
Subject: RE: $dbh->unquote()

At 12:24 -0500 3/27/03, Brian Spindler wrote:
>Interesting, in my MySQL database the field is a longtext should I change
it
>to a one of the binary types?

That won't make any difference.

I don't know how your problem occurred in fact, but here's one way that
it *can* occur.  Maybe this will shed some light on your problem.

$x = $dbh->quote ("\n");

$dbh->do ("INSERT INTO t SET col = $x");

That will insert a newline into the database.

$x = $dbh->quote ('\n');

$dbh->do ("INSERT INTO t SET col = $x");

That will insert a literal backslash-n into the database.

See the difference?



>
>Brian
>
>-----Original Message-----
>From: Sterin, Ilya (I.) [mailto:[EMAIL PROTECTED]
>Sent: Thursday, March 27, 2003 11:38 AM
>To: 'Brian Spindler'; 'Paul DuBois'; [EMAIL PROTECTED]
>Subject: RE: $dbh->unquote()
>
>This depends on what field in the db you are writting to.  If it's a raw
>type or binary field, then you wouldn't have that problem.  There might be
>some conversion going on between the db field, as \n is not a standard
>carriage return, it's the way Perl interpreter interprets carriage returns
>on what ever platform it was build on.  It might very possibly be converted
>between an ascii field and DBI.
>
>Ilya
>
>-----Original Message-----
>From: Brian Spindler [mailto:[EMAIL PROTECTED]
>Sent: Thursday, March 27, 2003 11:33 AM
>To: 'Paul DuBois'; [EMAIL PROTECTED]
>Subject: RE: $dbh->unquote()
>
>
>If printed in a windows environment "\n" is a carriage return.
>Brian
>
>
>-----Original Message-----
>From: Paul DuBois [mailto:[EMAIL PROTECTED]
>Sent: Thursday, March 27, 2003 11:32 AM
>To: Brian Spindler; [EMAIL PROTECTED]
>Subject: Re: $dbh->unquote()
>
>At 11:19 -0500 3/27/03, Brian Spindler wrote:
>>Hi guys, gals!
>>
>>      I have a pretty big string that I am inserting into MySQL via the
>>$dbh->quote($str) function, this works great however now when I pull the
>>data back out of the database and go to write it to a file the \n
>characters
>>that were inserted by quote are not being written back out as carriage
>>returns as desired.  How can do a reverse of quote() or just get those
>>"\n"'s to print out as they should! =) ahh.. I'm frustrated, I tried
>>everything even split('\n',$str) and then reinserting the "\n".  Doesn't
>>work, please help!
>>
>>Thanks in advance!
>>Brian
>
>What do you mean by "as they should"?  After all, "\n" isn't a carriage
>return.

Reply via email to