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

In reply to Re: Duplicity Check Help! by wallisds
in thread Duplicity Check Help! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.