Acá va el código (es un archivo muy largo, pongo lo que creo que corresponde) que debería mostrar las fotos:
Código:
Aquí van los archivos gralFunctions.php y showObjImage.php, que debería mostrar la foto<?php include("./admin/adf/bdADF.php"); include("./admin/functions/categoryFunc/gralFunctions.php"); include("./admin/functions/artistFunc/gralFunctions.php"); include("./admin/functions/objectFunc/gralFunctions.php"); connect_db(); if(isset($_GET["artistId"]) && isset($_GET["categoryId"])){ $objects = findCategoryObjects($_GET["categoryId"]); if(isset($_GET["objectId"])) $mainObject = findObjectByPk($_GET["objectId"]); $category = findCategoryByPk($_GET["categoryId"]); $categories = findCategoryByArtistId($_GET["artistId"]); $artist = findartistByPk($_GET["artistId"]); //print_r($categories); }else{ echo "Contact your administrator [ERROR: No artistId or categoryId]"; } ?> <?php if(isset($_GET["objectId"])) $objectIdtoShow = $_GET["objectId"]; else $objectIdtoShow = $objects[0]["id"]; ?> <img src="./admin/imageDisplayer/showObjImage.php?objectId=<?php echo $objectIdtoShow; ?>"width="389" height="293" border="0" /></td>
gralFunctions.php
Código:
showObjImage.phpfunction addObject($categoryId, $objectTitleFR, $objDescriptionFR, $objectTitleEN, $objDescriptionEN, $objectPrice) { $query = "select max(object.`displayOrder`) as maxOrder from `object`;"; $result = mysql_query($query); $array = array(); while( $row = mysql_fetch_assoc($result) ) { $array[] = $row; } $tmp = $array[0]["maxOrder"]; if( $tmp == null ) $tmp = 0; $tmp++; $fpOn = @fopen($_FILES["objectImage"]["tmp_name"][0], "rb"); $tfotoOn = @fread($fpOn, filesize($_FILES["objectImage"]["tmp_name"][0])); $tfotoOn = @addslashes($tfotoOn); fclose($fpOn); $fpOff = @fopen($_FILES["objectImage"]["tmp_name"][1], "rb"); $tfotoOff = @fread($fpOff, filesize($_FILES["objectImage"]["tmp_name"][1])); $tfotoOff = @addslashes($tfotoOff); fclose($fpOff); //$query = "INSERT INTO `object` (`title`, `description`, `price`, `mainImage`, `thumbnail`, `displayOrder`, `categoryId`) VALUES ('$objectTitle', '$objDescription', '$objectPrice', '$tfotoOn', '$tfotoOff', $tmp, $categoryId);"; // LecToro para dos idiomas: $query = "INSERT INTO `object` (`title_fr`, `description_fr`, `title_en`, `description_en`, `price`, `mainImage`, `thumbnail`, `displayOrder`, `categoryId`) VALUES ('$objectTitleFR', '$objDescriptionFR', '$objectTitleEN', '$objDescriptionEN', '$objectPrice', '$tfotoOn', '$tfotoOff', $tmp, $categoryId);"; $result = mysql_query($query) or die("<br>".mysql_error()); } function findAllObjects(){ $query = "select * from object order by object.`displayOrder`;"; $result = mysql_query($query); $array = array(); while($row = mysql_fetch_assoc($result)){ $array[] = $row; } return $array; } function findObjectsByCatId($categoryId){ $query = "select * from object where object.categoryId = $categoryId order by object.`displayOrder`;;"; $result = @mysql_query($query); $array = array(); if(@mysql_num_rows($result) > 0) { while($row = @mysql_fetch_assoc($result)){ $array[] = @$row; } } return $array; } function findObjectByPK($pk){ $query = "select * from object where id = $pk;"; $result = mysql_query($query); $array = array(); while($row = mysql_fetch_assoc($result)){ $array[] = $row; } return $array; } /* function modifyObject($pk, $objectTitle, $objDescription, $objectPrice){ $query = "UPDATE `object` SET `title`= '$objectTitle', `description`= '$objDescription', `price`= '$objectPrice' WHERE `id`=$pk;"; $result = mysql_query($query); } */ function modifyObject($pk, $objectTitleFR, $objDescriptionFR, $objectTitleEN, $objDescriptionEN, $objectPrice) { $query = "UPDATE `object` SET `title_fr`= '$objectTitleFR', `description_fr`= '$objDescriptionFR', `title_en`= '$objectTitleEN', `description_en`= '$objDescriptionEN', `price`= '$objectPrice' WHERE `id`=$pk;"; $result = mysql_query($query); } function deleteObject($pk){ $query = "DELETE FROM `object` WHERE `id`=$pk"; $result = mysql_query($query); } function moveObjectUp($pk, $catId){ $brotherObjectsQuery = "select object.`id`, object.`displayOrder` from object where categoryId = $catId order by object.`displayOrder`;"; $resultBrothers = mysql_query($brotherObjectsQuery); //$query = "select object.`id`, object.`displayOrder` from object order by object.`displayOrder`;"; //$result = mysql_query($query); $array = array(); $i = 0; $tmp = 0; while($row = mysql_fetch_assoc($resultBrothers)){ $array[] = $row; if($array[$i]["id"] == $pk){ $tmp = $i; } $i++; } //print_r($array); if($tmp != 0){ $toMoveUp = $array[$tmp]["id"]; $toUpPosition = $array[$tmp]["displayOrder"]; $tmp = $tmp - 1; $toMoveDown = $array[$tmp]["id"]; $toDownPosition = $array[$tmp]["displayOrder"]; $query = "UPDATE `object` SET `displayOrder`= $toDownPosition WHERE `id`=$toMoveUp;"; $result = mysql_query($query) or die("<br>".mysql_error()); $query = "UPDATE `object` SET `displayOrder`= $toUpPosition WHERE `id`=$toMoveDown;"; $result = mysql_query($query) or die("<br>".mysql_error()); } return $array; } function moveObjectDown($pk, $catId){ $query = "select object.`id`, object.`displayOrder` from object where categoryId = $catId order by object.`displayOrder`;"; $result = mysql_query($query); $array = array(); $i = 0; $tmp = 0; while($row = mysql_fetch_assoc($result)){ $array[] = $row; //print_r($array); if($array[$i]["id"] == $pk){ $tmp = $i; } $i++; } if($tmp < (sizeof($array) - 1)){ $toMoveUp = $array[$tmp]["id"]; $toUpPosition = $array[$tmp]["displayOrder"]; $tmp = $tmp + 1; $toMoveDown = $array[$tmp]["id"]; $toDownPosition = $array[$tmp]["displayOrder"]; $query = "UPDATE `object` SET `displayOrder`= $toDownPosition WHERE `id`=$toMoveUp;"; $result = mysql_query($query) or die("<br>".mysql_error()); $query = "UPDATE `object` SET `displayOrder`= $toUpPosition WHERE `id`=$toMoveDown;"; $result = mysql_query($query) or die("<br>".mysql_error()); } return $array; } ?>
Código:
<?php header('Content-Type: image/gif;'); header('Content-Type: image/jpeg;'); include("../adf/bdADF.php"); include("../functions/objectFunc/gralFunctions.php"); connect_db(); $object = findObjectByPk($_GET["objectId"]); $image = $object[0]["mainImage"]; echo $image; /* $query = "select mainImage as image from object where object.id = $objectId;"; $result = mysql_query($query); //echo $result[0]["image"]; $array = array(); while($row = mysql_fetch_assoc($result)){ $array[] = $row; } echo $array[0]["image"]; */ ?>
Si alguien puede echarnos una mano, mi amigo está de los pelos, y a mí me está volviendo loco.
como sé algo de php, pensé que sería facil, y he pasado varios períodos de 30 minutos de concentración en el sistema sin poder descularlo.
Gracias!