Page 1 of 1

Please Help With Script

Posted: Tue Aug 12, 2003 8:33 pm
by Adam
I need sone help, and I would appreciate any that anyone could provide. I have a script set up that uploads images path to my database, but I want it to upload the images to my server as well, and store the path in the database. The code looks like this.

Code: Select all

<?php
if ($action == "add") {

	if ($step == "2") {
	if ($folder == "") {
		print "You must fill in all feilds"; die;
	}
		if ($path == "") {
			print "You must fill in all feilds"; die;
	}
		if ($thumb == "") {
			print "You must fill in all feilds"; die;
	}

	$query="SELECT * FROM games WHERE gameid = '$gameid'";
	$result=mysql_query($query);
	$row = mysql_fetch_array($result);
	$gamename = "$row[gamename]";



	$linkID = @mysql_connect("$dbhost", "$dbuser", "$dbpassword");
	mysql_select_db("$dbname", $linkID) or die(mysql_error());

	$date = date("Y-m-d H:i:s");
	$resultID = mysql_query("INSERT INTO screenshots (screensid, folder, path, thumb, gameid, gamename, systemid, date) VALUES ('$screensid', '$folder', '$path', '$thumb', '$gameid', '$gamename', '$systemid', '$date')", $linkID) or die(mysql_error());
	if ($resultID == TRUE) {
		print "Screenshot was added to the database.<BR>";
	} else {
		print "Screenshot was not added to the database. Please try again.<BR>";
	}
}
else
{
	$query="SELECT * FROM games WHERE systemid = '$systemid'";
	$result=mysql_query($query);
	$row = mysql_fetch_row($result);
	$ngames = $row[0];
	if ($ngames == "") { print "There is not games in this system."; die; }

	echo "<form method="POST"action="?module=screenshots.php&action=add&step=2">
	<input type="hidden" name="systemid" value="$systemid">
  <table cellSpacing="0"cellPadding="5"width=668 border="0"height="546">
    <tr>
      <td vAlign="top"width=147 align="right"height="22">
      <p><font face=""Verdana"">Game:</font></td>
      <td vAlign="top"width=511 height="22"><b>
      <font face="Arial, Helvetica, sans-serif"size="2">
      <p align="left">";
	echo "<input type="hidden" name="systemid" value="$systemid">";
	$query="SELECT * FROM games WHERE systemid = '$systemid' ORDER BY gamename ASC";
	$result=mysql_query($query);
	echo "<select name="gameid" style="width:"100%";" tabindex="2">";
	while($row = mysql_fetch_object($result)) {
		echo "<option value="".$row->gameid.""";
		echo ">".$row->gamename."</option>";
	}
	echo "</select>";
      echo "</font></b></td>
    </tr>
    <tr>
      <td vAlign=top align="right" height="10">
      <face="Verdana">folder:</font></td>
      <td vAlign="top" height="10">
	  <input type="text" name="folder" size="20"></td>

    </tr>
        <tr>
	      <td vAlign=top align="right" height="10">
	      <face="Verdana">File Path:</font></td>
	      <td vAlign="top" height="10">
		  <input type="text" name="path" size="20"></td>

    </tr>
        <tr>
	      <td vAlign=top align="right" height="10">
	      <face="Verdana">thumb:</font></td>
	      <td vAlign="top" height="10">
		  <input type="text" name="thumb" size="20"></td>

    </tr>
    <tr>
      <td vAlign=top width=147 align="right"height="324">
      &nbsp;</td>
      <td vAlign="top"width=511 height="324">
      <p align="left"><BR>
  	 <p><input type="submit"value="Add Screenshots"name="B1"><input type="reset"value="Clear"name="B2"></p>
  		</td>
    </tr>
  </table>
</form>";
die;
}
}
?>
Once again, any help appreciated.
Thanks, Adam