#!C:\Perl\bin\perl
use strict;
use CGI;
use DBI;
# Read form data etc.
my $cgi = new CGI;
# The results from the high score script will be in plain text
print $cgi->header("text/plain");
my $playerName = $cgi->param('playerName');
my $score = $cgi->param('score');
# Connect to a database
my $dbh = DBI->connect( 'DBI:mysql:####', '####', '####' )
|| die "Could not connect to database: $DBI::errstr";
# Insert the player score if there are any
if( $playerName $score) {
$dbh->do( "insert into scores (Player, Score) values(?,?)",
undef, $playerName, $score );
}
# Fetch the high scores
my $sth = $dbh->prepare(
'SELECT player, score FROM scores ORDER BY score desc LIMIT 10' );
$sth->execute($Player);
while (my $r = $sth->fetchrow_arrayref) {
print join(':',@$r),"\n"
}
need a working one without using a pointless game variable