#=======================LOADING THE .TXT TO THE DATABASE============== +========== # get a list of all gamenames in the table my $select = $dbh->prepare( "SELECT gamename FROM games"); $select->execute() || die $dbh->errstr; # convert to hash for quick lookup in file-reading loop my %gamename_hash = (); while (my @gn = $select->fetchrow_array) { $gamename_hash{$gn[0]} = 1; } open (FILE, "<../data/games/descriptions.txt") or die $!; while (<FILE>) { chomp; next unless (length); # Skip if blank line my ($name, $desc) = split(/\t/, $_, 2); if ($gamename_hash{$name}) { # The gamename is already in the table. Increment the counter. $dbh->do( "UPDATE games SET gamecounter=gamecounter+1 WHERE (g +amename=?)", undef, $name) || die $dbh->errstr; } else { # The gamename is not in the table. Create a new record. $dbh->do( "INSERT INTO games (gamename, gamedesc, gamecounter) + VALUES (?,?,?)", undef, ($name, $desc, 0) ) || die $dbh->errstr; } } close (FILE);
Is more straightforward this way except the fact that each time i hit a game sumbit button all the counters are being increased, instead of the proper clicked one! and except that the execution of the code never enetes this section:
if( param('gamename') ) { $dbh->do( "UPDATE games SET gamecounter=gamecounter+1 WHERE gamena +me='$gamename'" ); $dbh->do( "UPDATE guestlog SET passage='$gamename' WHERE host='$ho +st'" ); $sth = $dbh->prepare( "SELECT * FROM games WHERE gamename=?" ); $sth->execute( $gamename ); $row = $sth->fetchrow_hashref; print span( {class=>'lime'}, "Είσαι ο $row->{gamecounter} ος πο +υ κατεβάζει το $row->{gamename} !!" ), br; print span( {class=>'yellow'}, "Ελπίζω να σου αρέσει και να σου φ +ανεί χρήσιμο!" ); print p( {-align=>'center'}, a( {href=>'index.pl'}, img {src=>'. +./data/images/back.gif'} )); print "<script language='Javascript'>location.href=/data/games/$ga +mename.rar</script>"; }
td( {-width=>'20%'}, submit( -name=>'gamename', -value=>$row->{gamename} )), is inside the form

In reply to Games.pl again by Nik

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.