my $dbh = DBI->connect('DBI:mysql:psa', 'admin', 'XXXXX') or die "Couldn't connect to database: " . DBI->errstr; my $sthGetBandwidth = $dbh->prepare('SELECT domains.name, hosting.real_traffic/1024/1024 FROM domains, hosting WHERE hosting.dom_id=domains.id LIMIT 10') or die "Couldn't prepare to get bandwidth: " . $dbh->errstr; my $remotedbh = DBI->connect('DBI:mysql:all34SP:, 'server', 'XXXXX') or die "Couldn't connect to remote database: " . DBI->errstr; my $sthUpdateBandwidth = $remotedbh->prepare('UPDATE users SET bandwidth=? WHERE address LIKE ?') or die "Couldn't prepare to update bandwidth: " . $remotedbh->errstr; my $sthGetOldBandwidth = $remotedbh->prepare('SELECT bandwidth FROM users WHERE address LIKE ?') or die "Couldn't prepare to get old bw: " . $remotedbh->errstr; $sthGetBandwidth->execute or die "Couldn't get bandwidth: " . $sthGetBandwidth->errstr; my @data; while (@data = $sthGetBandwidth->fetchrow_array()) { $sthGetOldBandwidth->execute($data[0]); unless ($sthGetOldBandwidth->rows == 0) { my @oldbw = $sthGetOldBandwidth->fetchrow_array(); my $newbw = sprintf '%.2f', $data[1]; print "Setting bandwidth for $data[0] to $newbw (was $oldbw[0])\n"; $sthUpdateBandwidth->execute($data[0], $newbw) or die "Couldn't update bandwidth for $data[0]: " . $sthUpdateBandwidth->errstr; } } #### Setting bandwidth for napiersnowsports.com to 3.92 (was 0.00) Setting bandwidth for pc-helper.net to 6.02 (was 0.00) Setting bandwidth for leemajors.co.uk to 144.66 (was 0.00) Setting bandwidth for kamonohashi.net to 0.00 (was 0.00) Setting bandwidth for smszone.net to 1.35 (was 0.00) Setting bandwidth for ukundergraduate.com to 0.31 (was 0.00) Setting bandwidth for win2000b.34SP.com to 0.07 (was 0.00) Setting bandwidth for mettacattery.org to 8.30 (was 0.00) Setting bandwidth for interlink-wireless.com to 2.57 (was 0.00) #### Setting bandwidth for napiersnowsports.com to 3.92 (was 0.00) Setting bandwidth for pc-helper.net to 6.02 (was 0.00) Setting bandwidth for leemajors.co.uk to 144.66 (was 0.00) Setting bandwidth for kamonohashi.net to 0.00 (was 0.00) Setting bandwidth for smszone.net to 1.35 (was 0.00) Setting bandwidth for ukundergraduate.com to 0.31 (was 0.00) Setting bandwidth for win2000b.34SP.com to 0.07 (was 0.00) Setting bandwidth for mettacattery.org to 8.30 (was 0.00) Setting bandwidth for interlink-wireless.com to 2.57 (was 0.00)