Aravinthan
New Member
- Messages
- 68
- Reaction score
- 0
- Points
- 0
Hi,
My guild asked recently started a in-guild league. And to ease up the leader's work I proposed to help him manage it. As he was doing everything manually changing points, adding game and all, I proposed to change the whole thing to databases. Everything went well, I've been able to add a way to add a player to the league, give him is win/defeat, give him is points. Update his recent games played. Now I am wondering how I can upload the recording of the games. Its a file that I would like to store in the database.
Here is the code I have so far:
THe form:
THanks for your help,
Ara
My guild asked recently started a in-guild league. And to ease up the leader's work I proposed to help him manage it. As he was doing everything manually changing points, adding game and all, I proposed to change the whole thing to databases. Everything went well, I've been able to add a way to add a player to the league, give him is win/defeat, give him is points. Update his recent games played. Now I am wondering how I can upload the recording of the games. Its a file that I would like to store in the database.
Here is the code I have so far:
THe form:
And the update file:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Insert New Game</TITLE>
<META NAME="Generator" CONTENT="TextPad 4.6">
<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
<form name="ladder Update" action="http://www.aoe3clan.com/index.php?name=Divison1&file=update2" method="post" ENCTYPE="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
Game ID:
</td>
<td>
<input type="text" name="gameid">
</td>
</tr>
<tr>
<td>
Player 1:
</td>
<td>
<input type="text" name="player1">
</td>
</tr>
<tr>
<td>
Player 2:
</td>
<td>
<input type="text" name="player2">
</td>
</tr>
<tr>
<td>
Winner:
</td>
<td>
<input type="text" name="winner">
</td>
</tr>
<tr>
<td>
Map:
</td>
<td>
<input type="text" name="map">
</td>
</tr>
<tr>
<td>
Record File:
</td>
<td>
<input type="file" name="file" id="file" />
</td>
</tr>
<tr>
<tr>
<td>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
Without the upload section, everything works fine. But when I add that, It doesnt. I dont get any error code or anything. Its blank, nothing gets loaded not even the title....<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Player Updated</TITLE>
<META NAME="Generator" CONTENT="TextPad 4.6">
<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
<?php
$gameid = $_POST['gameid'];
$player1 = $_POST['player1'];
$player2 = $_POST['player2'];
$winner = $_POST['winner'];
mysql_connect("host", "username", "pass") or die(mysql_error());
mysql_select_db("aoe3clan_division1") or die(mysql_error());
$sql="SELECT COUNT(*) AS count
FROM games
WHERE gameid='$gameid'";
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
if ($row['count']>0){
echo "There is already a game with this id. <a href='www.aoe3clan.com'>Home</a>";
}
else {
mysql_query("INSERT INTO games (gameid, player1, player2, winner, map)
VALUES ('$gameid', '$player1', '$player2', '$winner', '$map')");
print "Game $gameid has been successfully inserted into the database. Details:</br>GameId: $gameid</br> Player1: $player1</br> Player2: $player2</br> Winner:$winner</br> Map:$map</br>";
mysql_close($result);
$tmpName = $_FILES[’SpecialFile’][’tmp_name’];
$filesize = $_FILES[’SpecialFile’][’size’];
$filetype = $_FILES[’SpecialFile’][’type’];
$fp= fopen($tmpName, ‘r’);
$content = addslashes($content);
fclose($fp);
$filename = $player1 " .vs " $player2 " on " $map;
mysql_query("INSERT INTO UploadedFiles (name, size, type, content)
VALUES ('$filename', $filesize, '$filetype', '$content')");
$result = mysql_query($query);
if (!$result) {
dberror (mysql_error(), $_SERVER[’PHP_SELF’] );
echo mysql_error();
}
//Display Confirmation
print "</br> $filename has been succesfully uploaded</br>";
exit;
}
if ($winner == $player1) {
$result = mysql_query("SELECT * FROM player_stats WHERE name='$player1'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$oldp1 = $row['points'];
$newp1 = '3';
$point = $oldp1 + $newp1;
$oldgp1 = $row['gp'];
$newgp1 = '1';
$gp = $oldgp1 + $newgp1;
$oldwins1 = $row['wins'];
$newwins1 = '1';
$wins1 = $oldwins1 + $newwins1;
mysql_query("UPDATE player_stats SET points='$point', gp='$gp', wins='$wins1' WHERE name='$player1'")
or die(mysql_error());
print "$player1 has successfully received $newp1 points.";
}
mysql_close($result);
$result = mysql_query("SELECT * FROM player_stats WHERE name='$player2'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$oldp2 = $row['points'];
$newp2 = '1';
$point = $oldp2 + $newp2;
$oldgp2 = $row['gp'];
$newgp1 = '1';
$gp = $oldgp1 + $newgp1;
$oldloss2 = $row['loss'];
$newloss2 = '1';
$loss2 = $oldloss2 + $newloss2;
mysql_query("UPDATE player_stats SET points='$point', gp='$gp', defeats='$loss2' WHERE name='$player2'")
or die(mysql_error());
print "$player2 has successfully received $newp2 points. ";
}
}
else {
$result = mysql_query("SELECT * FROM player_stats
WHERE name='$player1'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$oldp1 = $row['points'];
$newp1 = '1';
$point = $oldp1 + $newp1;
$oldgp1 = $row['gp'];
$newgp1 = '1';
$gp = $oldgp1 + $newgp1;
$oldloss1 = $row['defeats'];
$newloss1 = '1';
$loss1 = $oldloss1 + $newloss1;
mysql_query("UPDATE player_stats SET points='$point', gp='$gp', defeats='$loss1' WHERE name='$player1'")
or die(mysql_error());
print "$player1 has successfully received $newp1 points. <a href='http://www.aoe3clan.com/test/ladder.php'> View the Ladder</a>";
}
mysql_close($result);
$result = mysql_query("SELECT * FROM player_stats WHERE name='$player2'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$oldp2 = $row['points'];
$newp2 = '3';
$point = $oldp2 + $newp2;
$oldgp2 = $row['gp'];
$newgp2 = '1';
$gp = $oldgp2 + $newgp2;
$oldwins2 = $row['wins'];
$newwins2 = '1';
$wins2 = $oldwins2 + $newwins2;
mysql_query("UPDATE player_stats SET points='$point', gp='$gp', wins='$wins2' WHERE name='$player2'")
or die(mysql_error());
print "</br>$player2 has successfully received $newp2 points. <a href='http://www.aoe3clan.com/test/ladder.php'> View the Ladder</a>";
}
}
}
?>
</BODY>
</HTML>
THanks for your help,
Ara