[Fwd: Irish Names and Forms.]

2000-06-09 Thread Mike Harris

I have a question on something similar, wonder if anyone can help?

Am doing the following:

1. Capturing an address from an HTML TEXTAREA form element, with
wrap=physical and multiple lines.
2. Am placing this into a MySQL database.
3. Am then running a report that dumps the database entries to a tab
deliminated or CSV file format to my web browser, for download and
import into a spreadsheet.

The problem I have is that the address ends up containing carridge
returns and line feed characters, so that when I extract the data and
import it, the spreadsheet treats these as record separators and breaks
the format.

The only way around I have at the moment is to use the following bit of
Perl:

$text =~s/\r\n/, /gm;

Which replaces the CRLF sequence (\r\n in Perl) with a comma and a
space.  Not great but works.

I also strip out tab characters:

$text =~s/\t//gm;   

Anyone got any better ideas?

Thanks,

Mike.

-- 
Mike Harris
Open Systems and Internet Consultant
Psand España, C/ de l'Encarnació 35 2º 2ª
08012 Barcelona, Spain
Tel: +34 93 213 6872 / +34 69 676 3122
Website: www.psand.net


---
F R E N D Z  of martian
---
> $text =~s/\'/\\\'/gm;  ?

I'll get my coat...
Brownie
(hmlt specialist)


-Original Message-
From: Martin Cosgrave [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 09, 2000 11:24 AM
To: multiple recipients of
Subject: Re: Irish Names and Forms.


---
F R E N D Z  of martian
---
> $text =~s/\'/\\\'/gm;

I would normally have it $text =~ s/\'/\\'/g; (dunno quite what m does in
yours - the camel book says 'treat as multiple lines' but not sure what that
means! g normally works for me)

Looks like you're storing the literal string \' into the database, whereas
with mine it stays as ' once it has got through the SQL parser.

Am I missing something...?

martian
(usual apols to non-techies)


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/




Re: Irish Names and Forms.

2000-06-09 Thread Mike Harris

---
F R E N D Z  of martian
---

In actual fact (I think), solely ' gets placed in the database because
the extra \' just escapes the sequence, 
and is ignored by (in this case) MySQL.

The m is just for good measure!

Mike.

Martin Cosgrave wrote:
> 
> ---
> F R E N D Z  of martian
> ---
> > $text =~s/\'/\\\'/gm;
> 
> I would normally have it $text =~ s/\'/\\'/g; (dunno quite what m does in
> yours - the camel book says 'treat as multiple lines' but not sure what that
> means! g normally works for me)
> 
> Looks like you're storing the literal string \' into the database, whereas
> with mine it stays as ' once it has got through the SQL parser.
> 
> Am I missing something...?
> 
> martian
> (usual apols to non-techies)
> 
> --
> Sent to you via the frendz list at marsbard.com
> 
> The archive is at http://www.mail-archive.com/frendz@marsbard.com/

-- 
Mike Harris
Open Systems and Internet Consultant
Psand España, C/ de l'Encarnació 35 2º 2ª
08012 Barcelona, Spain
Tel: +34 93 213 6872 / +34 69 676 3122
Website: www.psand.net


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/




RE: Irish Names and Forms.

2000-06-09 Thread Paul_Brownsmith

---
F R E N D Z  of martian
---
> $text =~s/\'/\\\'/gm;  ?

I'll get my coat...
Brownie
(hmlt specialist)


-Original Message-
From: Martin Cosgrave [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 09, 2000 11:24 AM
To: multiple recipients of
Subject: Re: Irish Names and Forms.


---
F R E N D Z  of martian
---
> $text =~s/\'/\\\'/gm;

I would normally have it $text =~ s/\'/\\'/g; (dunno quite what m does in
yours - the camel book says 'treat as multiple lines' but not sure what that
means! g normally works for me)

Looks like you're storing the literal string \' into the database, whereas
with mine it stays as ' once it has got through the SQL parser.

Am I missing something...?

martian
(usual apols to non-techies)


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/




Re: Irish Names and Forms.

2000-06-09 Thread Martin Cosgrave

---
F R E N D Z  of martian
---
> $text =~s/\'/\\\'/gm;

I would normally have it $text =~ s/\'/\\'/g; (dunno quite what m does in
yours - the camel book says 'treat as multiple lines' but not sure what that
means! g normally works for me)

Looks like you're storing the literal string \' into the database, whereas
with mine it stays as ' once it has got through the SQL parser.

Am I missing something...?

martian
(usual apols to non-techies)


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/




Irish Names and Forms.

2000-06-08 Thread Mike Harris

---
F R E N D Z  of martian
---
I live in Spain and my address: C/ de l'Encarnació serious fucks SQL as
well.  

The ' screws it up and so does the /.  So I have a my favourite perl sub
of all time for you:


##
# Sub:  strip_quotes
# Version:  1.0
# Description:  replaces \, ' and " with \\, \' and \" respect.
#   in order to insert text fields in database, these
#   escape the string and make the SQL work.
# 

sub strip_quotes {

my $text = shift;

$text =~s/\\//gm;
$text =~s/\'/\\\'/gm;
$text =~s/\"/\\\"/gm;
return $text;
}


I love it, but Iain tells me there's a better way of doing this, but as
I wrote it, I'm gonna keep using it!

Mike.

P.S.  I'm not a member, but I hope it's alright to send?

-- 
Mike Harris
Open Systems and Internet Consultant
Psand España, C/ de l'Encarnació 35 2º 2ª
08012 Barcelona, Spain
Tel: +34 93 213 6872 / +34 69 676 3122
Website: www.psand.net


--
Sent to you via the frendz list at marsbard.com

The archive is at http://www.mail-archive.com/frendz@marsbard.com/