Incidentially, (and please don't take this as being picky, merely an
observation)
I have found that the qq method does not work 100% of the time, also!
I've had to change code that was produced by an external contractor that
was using this
method and failing on unquoted apostrophes. Changed to DBI->quote and it
was fine.
Another point to mention is that DBI->quote looks not only at the value
being inserted,
but also to the data_type of the table/field it's going into, and
replaces undef values
with an unquoted NULL value, if appropriate.
This is especially handy with the map DBI->quote method from earlier.
I guess it's just a case of applying the best solution for a given
circumstance.
Dave
"PURMONEN, Joni" wrote:
>
> David's method is probably better, but I still use just a long row of ?
> marks even in this situations. 20 odd question marks is not too bad ;)
>
> Somehow I've had more problems with the $dbh->quote($str) which very well
> may be because of my own errors.
>
> J
>
> -----Original Message-----
> From: borakovej [mailto:[EMAIL PROTECTED]]
> Sent: 18 July 2001 18:04
> To: PURMONEN, Joni; [EMAIL PROTECTED]
> Subject: Re: Think there is something DBI
>
> that would work if it where a little insert but this is what the insert
> looks like
>
> $SQL_UP = qq`
> Insert into $DB_Table
> (firstname,lastname,title,phone,email,age,location,address,address2,city,sta
> te,zip,zip2,inst,school_type,grades_taught,subjectarea_1,subjectarea_2,subje
> ctarea_3,subjectarea_4,subjectarea_5,subjectarea_6,how_heard,Occupation)
>
> Values
> ('$firstname','$lastname','$title','$phone','$email','$age','$location','$ad
> dress','$address2','$city','$state','$zip','$zip2','$inst','$school_type','$
> grades_taught','$subjectarea_1','$subjectarea_2','$subjectarea_3','$subjecta
> rea_4','$subjectarea_5','$subjectarea_6','$how_heard','$Occupation')`;
>
> ----- Original Message -----
> From: "PURMONEN, Joni" <[EMAIL PROTECTED]>
> To: "'borakovej'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, July 18, 2001 6:59 AM
> Subject: RE: Think there is something DBI
>
> > yep, couple of ways, placeholders being the best ones. Slurp the data into
> a
> > string and then
> >
> > $sql = qq(UPDATE whatever
> > SET this = ?
> > WHERE id =?);
> >
> > $sth=$dbh->prepare($sql);
> > $sth->execute($this,$id);
> >
> > This way you do not need to worry about apostrophes in the strings $this
> or
> > $id.
> >
> > Joni
> >
> > -----Original Message-----
> > From: borakovej [mailto:[EMAIL PROTECTED]]
> > Sent: 18 July 2001 17:31
> > To: [EMAIL PROTECTED]
> > Subject: Think there is something DBI
> >
> >
> > OK here is an overview of my problem, I am running a script to take a pipe
> > delimited flat file and pump the data into a database. Due to the users
> > putting extraneous apostrophes I am getting errors that there are unclosed
> > apostrophes in the fields. I am looking for a way to escape these
> > apostrophes as simply as possible. Can someone help?
> >
> > Judd Borakove
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
David Wood, Web Developer<br>
[a] Clickmusic Ltd, 99c Talbot Road, London W11 2AT<br>
[t] 020 7727 7500
<br>[w] www.clickmusic.co.uk<br>
<br>"There are three types of people in the world; those who can count,
and those who can't."
<br> </html>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]