I'm trying to get some "INSERT" statements running on Perl but for some reason, the insert is executed twice!
Here's a snippet of the code:
Code:
What it does is it processes a text file, inserting each of the lines contained within it. I've done a "print" of the SQL just before the execute, and it only prints out 7 insert commands (which is correct as I have 7 lines in the text file im testing with). And I have also exited the loop straight after the execute statement, but it STILL gets inputted twice!!
Heeeeeelp!
Here's a snippet of the code:
Code:
Code:
if(Encode::is_utf8("$line")) {
$sqlstatement=
qq{
insert into items (parentid,title,description,archivedate,archiveid,imagename,status,indexed) values ($parentid,N'$fields[2]',N'$fields[4]',N'$fields[3]',$archiveid,N'$image',0,0)
};
}
else {
$sqlstatement=
qq{
insert into items (parentid,title,description,archivedate,archiveid,imagename,status,indexed) values ($parentid,'$fields[2]','$fields[4]','$fields[3]',$archiveid,'$image',0,0)
};
}
$sth = $db->prepare("$sqlstatement");
$sth->execute();
What it does is it processes a text file, inserting each of the lines contained within it. I've done a "print" of the SQL just before the execute, and it only prints out 7 insert commands (which is correct as I have 7 lines in the text file im testing with). And I have also exited the loop straight after the execute statement, but it STILL gets inputted twice!!
Heeeeeelp!