...
if(@pics)
{
my $dbh = SQLStuff->connect_mysql();
my $sth = $dbh->prepare("select * from test_users where user = ? ") or &justdie("Can't select from table: ",$dbh->errmsg);
$sth->execute($got_user_name);
#my (@pic1,@pic2,@pic3,@pic4,$flag_pic);
my $flag_pic;
while (my $row = $sth->fetchrow_hashref())
{
#push @pic1,$row->{image_name_1} || '';
#push @pic2,$row->{image_name_2} || '';
#push @pic3,$row->{image_name_3} || '';
#push @pic4,$row->{image_name_4} || '';
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";}
if(($row->{image_name_3} ne "") eq ($pics[2] ne "")){$flag_pic="1";}
if(($row->{image_name_4} ne "") eq ($pics[3] ne "")){$flag_pic="1";}
}
#my $check_pic1 = shift(@pic1);
#my $check_pic2 = shift(@pic2);
#my $check_pic3 = shift(@pic3);
#my $check_pic4 = shift(@pic4);
print "
751**$flag_pic**
";
# End check
if($flag_pic ne "1")
{
my $dbh = SQLStuff->connect_mysql();
my $sth = $dbh->prepare("insert into test_add(image_1,image_2,image_3,image_4,image_loc,user) values(?, ?, ?, ?, ?,?)")
or &justdie("Can't add data, please try again later! ",$dbh->errmsg);
$sth->execute((@pics, undef, undef, undef, undef)[0..3],$path_loc[0],$got_user) or &justdie("Can't select from table: ",$dbh->errmsg);
}
}
...