my image upload please

Status
Not open for further replies.

TheBoom

Beta member
Messages
3
hello

i made an image upload system.

but i have a problem, if i upload one file with one images its ok but if i upload another file with two images it shows the second image everywhere where is suppose to be one.

here is my coding

body_command = mysql_query("SELECT descr, image1, image2 FROM books WHERE id=".$row["id"]." ");
$body = mysql_fetch_array($body_command);

if($row["image1"] OR $row["image2"])
{
if ($body["image1"] != "") {
if($body["image1"] != "")
$img1 = "<a href='books/images/$body[image1]' rel='shadowbox' target='_blank'><IMG src='books/images/".$row["image1"]."' width='150'height='120' border='0'></a>";
if($body["image2"] != "")
$img2 = "<a href='books/images/$body[image2]' rel='shadowbox' target='_blank'><IMG src='books/images/".$row["image2"]."' width='150' height='120' border='0'></a>";
echo("<CENTER>Images:<br>". $img1 . "&nbsp&nbsp". $img2 . "</CENTER> ");

}
}

some one could give me a hint what i messed up?

thank you
 
this is it

Code:
$ret = mysql_query("INSERT INTO books (search_text, filename, owner, visible, info_hash, name, size, numfiles, type, descr, ori_descr, image1, image2, category, save_as, added, last_action, nfo, comm_enabled, cover) VALUES (" .
                implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $uploaderid, "no", $infohash, $torrent, $totallen, count($filelist), $type, $descr, $descr, $inames[0], $inames[1], 0 + $_POST["type"], $dname))) .
                ", '" . get_date_time() . "', '" . get_date_time() . "', $nfo, '".$comm_enabled."', '".$cover."')");
 
This highlights perfectly the need to lay code out properly. Another tip is to keep language code and functions out of things like SQL queries. This is your code but laid out differently:
Code:
$whoKnows = 0 + $_POST["type"];

$searchText = implode(",",
	array_map("sqlesc",
		array(searchfield("$shortfname $dname $torrent"),
			$fname,
			$uploaderid,
			"no",
			$infohash,
			$torrent,
			$totallen,
			count($filelist),
			$type,
			$descr,
			$descr,
			$inames[0],
			$inames[1],
			$whoKnows,
			$dname)));

$queryTime = get_date_time();

$sql = <<<EOT
	INSERT INTO books(
		search_text,
		filename,
		owner,
		visible,
		info_hash,
		name,
		size,
		numfiles,
		type,
		descr,
		ori_descr,
		image1,
		image2,
		category,
		save_as,
		added,
		last_action,
		nfo,
		comm_enabled,
		cover)
	VALUES(
		$searchText,
		$queryTime,
		$queryTime,
		$nfo,
		$comm_enabled,
		$cover)
EOT;

$ret = mysql_query ($sql);
 
Status
Not open for further replies.
Back
Top Bottom