http://qs321.pair.com?node_id=874917


in reply to Duplicity Check Help!

I would be interested to see the description of your table 'test_add'.

But in the meantime here are some of my initial suggestions:
my $flag_pic; I would define it and turn on warnings (if not already on): use warnings;
And for the defining part change my $flag_pic; to
my $flag_pic = 0;
Also, where you say :
$flag_pic+="1";
I think you should take away the quotes and try this please:
$flag_pic+=1;
Now if I understand your question correctly you don't want to add any duplicate images into your table and you are checking this based on the value of $flag_pic.

I notice you are saying if ($flag_pic ne "1") { #insert }
but you are adding 1 up to 4 times (given the if statements succeed) in your while loop (as shown here so you know what I'm trying to say)
if ( ($row->{image_name_1} ne "") eq ($pics[0] ne "") ) { $flag_pic += "1"; } if ( ($row->{image_name_2} ne "") eq ($pics[1] ne "") ) { $flag_pic += "1"; } #and all the way to image_name_4
... so if you have two cases where the if succeeds, $flag_pic will be set to 2, not 1, and if you have three, $flag_pic = 3, and so forth. So in any case where more than one if-statement succeeds in your while loop $flag_pic will NOT EQUAL 1.

I recommend changing your if-statement at the bottom to
if ($flag_pic == 0) { #insert }

See if any of that helps.
-Dawn