Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 05-22-2009, 08:31 AM   #1 (permalink)
 
Newb Techie

Join Date: May 2009

Posts: 3

TheBoom is on a distinguished road

Default my image upload please

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

Quote:
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
TheBoom is offline  
Old 05-22-2009, 02:57 PM   #2 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,683

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: my image upload please

Show me more code, like the code you use to insert into the database.
__________________

Need website help? PM me!
CrazeD is offline  
Old 05-23-2009, 07:49 AM   #3 (permalink)
 
Newb Techie

Join Date: May 2009

Posts: 3

TheBoom is on a distinguished road

Default Re: my image upload please

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."')");

TheBoom is offline  
Old 05-23-2009, 10:04 AM   #4 (permalink)
 

Join Date: Jul 2005

Location: England

Posts: 2,158

kmote has a spectacular aura aboutkmote has a spectacular aura about

Default Re: my image upload please

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);

__________________
MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11


There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
kmote is offline  
Old 05-23-2009, 10:59 AM   #5 (permalink)
 
Newb Techie

Join Date: May 2009

Posts: 3

TheBoom is on a distinguished road

Default Re: my image upload please

thankyou for your help
TheBoom is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Upload Software Osiris Tips, Tricks & Tutorials 0 05-03-2009 12:29 PM
New Rig - XP sees SATA. Hardy doesn't. Jayce Linux, BSD, other *nixes & Open Source Software 30 10-11-2008 09:28 PM
Double clicking an image opens windows photo gallery instead of preview the image djfiasco Windows Operating Systems and Software 10 03-03-2008 11:35 PM