Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need 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

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-24 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found