|  |
05-22-2009, 08:31 AM
|
#1 (permalink)
|
Newb Techie Join Date: May 2009 Posts: 3
| 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 . "  ". $img2 . "</CENTER> ");
}
}
| some one could give me a hint what i messed up?
thank you |
| |
05-22-2009, 02:57 PM
|
#2 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,683
| Re: my image upload please Show me more code, like the code you use to insert into the database.
__________________ Need website help? PM me! |
| |
05-23-2009, 07:49 AM
|
#3 (permalink)
|
Newb Techie Join Date: May 2009 Posts: 3
| 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."')");
|
| |
05-23-2009, 10:04 AM
|
#4 (permalink)
|
Join Date: Jul 2005 Location: England Posts: 2,158
| 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 |
| |
05-23-2009, 10:59 AM
|
#5 (permalink)
|
Newb Techie Join Date: May 2009 Posts: 3
| Re: my image upload please thankyou for your help |
| |  | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |