In order to get quoting to work, your best bet is to use placeholders, which
are automatically populated/quoted for you. My solution would be (and I'm no
expert):
Replace:
$temval = "(".join(",",@sbval ).")";
With:
$temval = "(".join(", ", map("?", @sbval)).")";
(which creates a string : "?,?,?,?,?,?" replacing the values from @sbval)
And add the following after your prepare statement:
my $f=1;
foreach my $value (@sbval) {
$statement->bind_param($f++, $value);
}
Happy for people to improve on this, though!
-----Original Message-----
From: kaustubh shinde [mailto:[EMAIL PROTECTED]
Sent: 30 July 2004 09:35
To: [EMAIL PROTECTED]
Subject: insert into statement problem
Hi,
I have been trying to read data from a hash and put it into myaql using
insert into statement.
foreach $key (keys %submt_feat)
{
if($submt_feat{$key}){
$submt_feat{$key}= $submt_feat{$key};
push(@sbft,$key);
push(@sbval,$submt_feat{$key});
}
}
$temfeat = "(".join(",",@sbft).")";
$temval = "(".join(",",@sbval ).")";
$ins = "insert into submitter ";
$statement = $ins.$temfeat." values ".$temval.";";
$statement = $dbh->prepare($statement);
$statement->execute();
but it doesnt work because the values need quotes around them since its
varchar type.
i am not able to get quotes around them. This is very urgent and I will
really really appreciate any ideas.
Thank you,
Kaustubh
_________________________________________________________________
Studies, career, romance. Whatever your concerns.
http://www.astroyogi.com/newMSN/ We have the answers.
This e-mail and any attachment is for authorised use by the intended recipient(s)
only. It may contain proprietary material, confidential information and/or be subject
to legal privilege. It should not be copied, disclosed to, retained or used by, any
other party. If you are not an intended recipient then please promptly delete this
e-mail and any attachment and all copies and inform the sender. Thank you.