I know I'm thinking too hard on this but I'm missing the obvious way to go about doing this.

I have a forum (SMF) on my site. I want to log into that database and pull everyone's username and current post count. I then setup a new database (called 'contest', table called 'entrants') in which I want to dump every username and count total that is > 0.

From there, the contest db has 3 total fields (username, original and current). Original is the first time it found their name and dumped their post count (this won't change). Current is each time after that that shows what their CURRENT post count is.

But how do I do that? I'm not sure why I'm confused. I need to update if the username was already found but setup a new entry in my new database if they weren't in there yet. How do I do this? It's going to be one script that does both..

This is what I have so far to show you what I'm trying to do

#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use warnings; use strict; use CGI qw/:standard/; use DBI; ################### # configurations ################### my $dbase = "everyday_forum"; my $mysql_user = "everyday_everyda"; my $mysql_pass = ""; my $dbase2 = "everyday_contest"; my $mysql_user2 = "everyday_everyda"; my $mysql_pass2 = ""; ################### # end configurations ################### print header; my $dbh = DBI->connect("DBI:mysql:$dbase", $mysql_user, $mysql_pass) o +r print DBI->errstr; my $dbh = DBI->connect("DBI:mysql:$dbase2", $mysql_user2, $mysql_pass2 +) or print DBI->errstr; ###################################### # first things first, read from chat database and pull back everyone w +ith a positive post count ######################################## my $data = qq(SELECT memberName, posts FROM smf_members where posts > +"0"); my $sth = $dbh->prepare($data); $sth->execute() or die $dbh->errstr; my ($name, $posts); $sth->bind_columns(\$name, \$posts); while($sth->fetch) { print "$name -> $posts<br>"; my $data = qq(INSERT into forum ( }

In reply to database setup 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":



  • 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.