I have created a database called "test" and even have a table called "replays" when i upload my replay files, i can see it in my database through myPHPADMIN but it does not upload into the folder /upload nor does it display on the display page where i want it to which is the display_rep.php can you tell me what's the problem, here I'll give you the scripts.
upload.php
http://www.dangmn.net/hp/upload.php
<html>
<body>
<form action="process_upload.php" method="post"
<label for="file">Replay:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="Upload" value="Submit" />
</form>
</body>
</html>
Process_Upload.php
http://www.dangmn.net/hp/process_upload.php
<?php
$db = mysql_connect('localhost', 'dangmnne_dangmnx', 'password'); //fill in host, hostname, hostpass with your own
if (!$db)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('dangmnne_test', $db); //fill in DBname with your own
if (!db_selected)
{
die("cant connect");
}
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
$replay = "upload/" . $_FILES["file"]["name"];
$replay2 = "<a href=\"http://www.dangmn.net/hp/upload/" .$replay. "\"><img src = \"http://www.dangmn.net/image.jpg\" style=\"border-style: none\"/></a>"; //replace "yoursite" with your own site
$query = "INSERT INTO test (replay)
VALUES ('".$replay2."')";
$result = mysql_query($query) or die(mysql_error());
mysql_close($db);
}
?>
display_rep.php
http://www.dangmn.net/hp/display_reps.php
<?php
$db = mysql_connect('localhost', 'dangmnne_dangmnx', 'dn249118'); //fill in host, hostname, hostpass with your own
if (!$db)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('dangmnne_test', $db); //fill in DBname with your own
if (!db_selected)
{
die("cant connect");
}
$result = mysql_query("SELECT replay FROM test");
echo "<table ALIGN='center' border='1'>
<tr>
<th><FONT COLOR='#000'>Replay</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td ALIGN='CENTER'><FONT COLOR='#000'>" . $row['replay'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($db);
?>