hi. my $row[1], $row[2], and $row[3] variables get overwritten in the below program, once the user hits the "submit" button.. ive no idea why? please help.
#!/usr/bin/perl use DBI; use CGI qw/:standard *table start_ul/; $db_host = "localhost"; $db_user = "myuser"; $db_pass = "mypass"; my $dbh = DBI->connect("DBI:mysql:database=fnoofs;host=$db_host", $db_ +user, $db_pass, {'RaiseError' => 1}); opendir(DIR, "/web/htdocs/images/fnoofus") or die "wtf.. $!"; @allfiles = grep { $_ ne '.' and $_ ne '..' } readdir DIR; closedir DIR; print header, start_html('Fnoofus Admin Page'), start_form; $num = 0; print "begin foreach loop<br>"; foreach $file (@allfiles) { print "incrementing num<br>"; $num++; @checkname[$num] = $file . "_db"; $sth = $dbh->prepare("select * from fnoofus where picname='$file +'"); $number = $sth->execute(); print "<br>begin if loop<br>"; if ($number > 0) { print "begin while loop<br>"; while (@row = $sth->fetchrow_array) { print "<table>"; print "<tr><td rowspan=\"4\">"; print "<img src=\"/images/fnoofus/$file\"></td>"; print "<td valign=\"top\">"; print "Image location: ", textfield(-name=>'imageLoc',-defa +ult=>$row[1],-size=>50,-maxlength=>80),p; print "</td></tr><tr><td>"; print "Description: ", textfield(-name=>'description',-defa +ult=>$row[2],-size=>55),p; print "</td></tr><tr><td>"; print "Picname: ", textfield(-name=>'picname',-default=>$ro +w[3],-size=>20),p; print "</td></tr><tr><td valign=\"top\">"; print checkbox(-name=>$checkname[$num],-checked=>1,-value=> +'ON'); print "</td></tr>"; print "</table>", hr; } } else { print "<table>"; print "<tr><td rowspan=\"4\">"; print "<img src=\"/images/fnoofus/$file\"></td>"; print "<td valign=\"top\">"; print "Image location: ", textfield(-name=>'imageLoc',-defa +ult=>'nothing here',-size=>50,-maxlength=>80),p; print "</td></tr><tr><td>"; print "Description: ", textfield(-name=>'description',-defa +ult=>'nothing here',-size=>55),p; print "</td></tr><tr><td>"; print "Picname: ", textfield(-name=>'picname',-default=>'no +thing here',-size=>20),p; print "</td></tr><tr><td valign=\"top\">"; print checkbox(-name=>$checkname[$num],-checked=>0,-value=> +'OFF'); print "</td></tr>"; print "</table>", hr; } } print submit, end_form; if (param()) { foreach $check (@checkname) { if (param($check)) { print "$check<br>"; } } }

In reply to variables get overwritten (loop problem? i dunno) by vxp

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.