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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |