For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > August 2005 > Re: quote problem and mysql









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: quote problem and mysql
Todd W

2005-08-04, 5:00 pm

"Andrew Kennard" <a.kennard@btinternet.com> wrote in message
news:20050715085431.20708.qmail@lists.develooper.com...
> Hi all
>


<snip />

>
> my $Vals;
> for ( my $i=1;$i<=32;$i++ ) {
> $Vals.='?,';
> }
> chop $Vals;


Ugh.

$vals = join(', ', ('?') x 32 );

Ideally, you should have your data in an array, then:

my $sql = "INSERT INTO table VALUES (${ \join(', ', map('?', @data)) })";
$dbh->do( $sql, undef, @data );

Todd W.




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com