Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/12/2008, 16:21
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 10 meses
Puntos: 220
De acuerdo Mostrar Imagen de SQL Server en PHP

hola a todos mi consulta es la siguiente tengo una tabla con los siguientes campos:
CREATE TABLE SERVICIOS(
COD_SER varchar(10) not null,
NOMBRE varchar(150) null,
FOTO image null,
DESCRIPCION varchar(150) null,
FECHA_REG datetime null,
ESTADO int null,
primary key(COD_SER))

en php tengo dos consultas una para q me genere los registros y otra para q me devuelva la imagen
1.- la primera es la siguiente prueba.php
<?php
$Rs=mssql_query("select * from servicios");
?>
<table width="750" border="1" align="center" cellpadding="5" cellspacing="0">
<tr>
<th scope="col">CODIGO</th>
<th scope="col">NOMBRE</th>
<th scope="col">FOTO</th>
<th scope="col">DESCRIPCION</th>
<th scope="col">FECHA</th>
<th scope="col">ESTADO</th>
</tr>
<?php
while($Data = mssql_fetch_assoc($Serv))
{
echo "<tr>";
echo "<th>".$Data['COD_SER']."</th>";
echo "<th>".$Data['NOMBRE']."</th>";
echo "<th><img src=\"img.php?Cod='".$Data['COD_SER']."'\" alt='Error'";//aqui envio a mi otro php el codigo de la imagen para buscar la foto
echo "<th>".$Data['DESCRIPCION']."</th>";
echo "<th>".$Data['FECHA_REG']."</th>";
echo "<th>".$Data['ESTADO']."</th>";
echo "</tr>";
}
?>
</table>



2.- la segunda consulta es para q me devuelva la imagen de la BD img.php
<?php
include_once("PHP/SQL/ClsSQL.php");
$SQL = new ClsSQL();
$SQL->Conexion();
$Foto = $_GET['Cod'];//valor q recibo de mi primer php
$Foto = "SER00001";
$Serv = $SQL->SQLCommand("SELECT FOTO FROM SERVICIOS WHERE COD_SER='".$Foto."'");//me devuelve un solo registro
$Img=@mssql_fetch_assoc($Serv);
header( "Content-type: image/jpeg"); //aqui digo q me devuelva en tipo jpg
echo $Img["FOTO"];//aqui envio el campo
?>

pero al ejecutar la prueba.php no me devuelve nada de la imagen q tengo guardado en mi Bd estoy desesperado he intentado todo me pueden decir q es lo q me falta o q he hecho mal porfis ayuda