At first I thought this would be a MySQL question but oddly enough it's saying I'm not declaring two of my variables (which I can't see how that is).

The errors revolve around

my @row; my $cnt = -1; while(@row = $sth->fetchrow_array) { $cnt++; print "$row[$cnt] test<br>"; }
In which its saying
Global symbol "@row" requires explicit package name at admin.pl line 1 +65. Global symbol "$cnt" requires explicit package name at admin.pl line 1 +65. Global symbol "@row" requires explicit package name at admin.pl line 1 +65. Global symbol "$cnt" requires explicit package name at admin.pl line 1 +65. Global symbol "@row" requires explicit package name at admin.pl line 1 +65. Global symbol "$cnt" requires explicit package name at admin.pl line 1 +65.
However, I am indeed predeclaring both @row and $cnt before the loop even begins. So something else must be wrong and I can't put my finger on it.

Can someone see where I goofed in the code below?

if ($action =~ m/upload/i) { print <<" EOF"; <table width="400" border="1" cellspacing="0" bordercolor="#0000 +FF"> <form action="" method="post" enctype="multipart/form-data"> <tr> <td width="456" height="53"><table width="447" cellspacin +g="0"> <tr bgcolor="#FFCCFF"> <td colspan="2"><div align="center">Upload file to user < +/div></td> </tr> <tr> <td width="234">File:</td> <td width="206"><input name="upload" type="file" id="uplo +ad"></td> </tr> <tr> <td>User:</td> <td><select name="select" MULTIPLE size="5"> END my $data = qq(SELECT username FROM login); my $sth = $dbh->prepare($data); $sth->execute() or die $sth->errstr; my @row; my $cnt = -1; while(@row = $sth->fetchrow_array) { $cnt++; print "$row[$cnt] test<br>"; } print <<" EOF"; </select></td> </tr> <tr> <td colspan="2"><div align="center"> <input name="UploadFile" type="submit" id="UploadFile" value +="Upload"> </div></td> </tr> </table></table> EOF }

In reply to Problems with sth->fetchrow array or another syntax error by coldfingertips

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.