Foros del Web » Programando para Internet » PHP »

problema para mostrar una imagen con php

Estas en el tema de problema para mostrar una imagen con php en el foro de PHP en Foros del Web. Hola yo soy un novato en esto de php y estoy haciendo un sistema de noticias con un manager el manager hasta donde voy me ...
  #1 (permalink)  
Antiguo 12/11/2005, 14:36
 
Fecha de Ingreso: mayo-2004
Ubicación: Ciudad de la Habana
Mensajes: 85
Antigüedad: 19 años, 11 meses
Puntos: 0
problema para mostrar una imagen con php

Hola yo soy un novato en esto de php y estoy haciendo un sistema de noticias con un manager el manager hasta donde voy me trabaja bien pero a la hora de mostrar la imagen en el sistema de noticias no me la muestra aquí les envío el cogido de la parte encargada de mostrar la noticia para que me den una mano y me digan en que estoy errado.

Salu2, y mil gracias
choco_cu
aquí les envio el codigo
Código PHP:
<?php 
$id 
$_GET[id];
$connect mysql_connect('localhost','manuel','kimeramarukun');
mysql_select_db('cancunpendulo',$connect);
$result =mysql_query("Select * from noticias where id = '$id'",$connect); 
while (
$row mysql_fetch_array($result)){?>
<table width="360" height="450">
   <tr>
    <td valign="top"><?php
$fechainv 
str_replace('-','/',$row[fecha]);
$path '/img/secciones/'.$row[seccion].'/'.$fechainv.'/'.'portada.jpg';
echo 
'<h5 valign=top style=color:#950004; font-size:14px; font-family:Tahoma, Verdana; text-decoration:none>'.$row[titular].'</h5>';
if (
file_exists($path)){?>
<img src="<?php echo $path ?>" alt="Portada" width="50"  height="50" hspace="10" vspace="3" border="0" align="right">;
<?php };?>
<?php
echo '<p valign=top style=color:#a000000; font-size:14px; font-family:Tahoma, Verdana; text-decoration:none>'.$row[ampliada].'<br><br><strong style=color:#FF4A4A; font-size:14px; font-family:Tahoma, Verdana; text-decoration:none>'.$row[fuente].'</strong>';} ?>
   </td>
  </tr>
</table>
<?php
mysql_free_result
($result);
mysql_close($connect);?>
  #2 (permalink)  
Antiguo 12/11/2005, 15:05
Avatar de Quest  
Fecha de Ingreso: diciembre-2002
Ubicación: Santiago
Mensajes: 129
Antigüedad: 21 años, 4 meses
Puntos: 2
y cual error te envia???
__________________
http://victorsanmartin.com
Web Developer
http://www.guiasitios.cl
  #3 (permalink)  
Antiguo 12/11/2005, 17:44
 
Fecha de Ingreso: mayo-2005
Mensajes: 72
Antigüedad: 18 años, 10 meses
Puntos: 1
hola, en tu codigo tienes varios errores, lo arregle prueba este:

Código PHP:
<?php 
$id 
$_GET['id']; 
$connect mysql_connect("localhost","manuel","kimeramarukun"); 
mysql_select_db("cancunpendulo",$connect); 
$result =mysql_query("Select * from noticias where id = '$id'",$connect); 
while (
$row mysql_fetch_array($result)){?> 
<table width="360" height="450"> 
   <tr> 
    <td valign="top"><? 
$fechainv 
str_replace("-","/",$row['fecha']); 
$path "/img/secciones/".$row['seccion']."/".$fechainv."/"."portada.jpg"
echo 
'<h5 valign=top style=color:#950004; font-size:14px; font-family:Tahoma, Verdana; text-decoration:none>'.$row['titular'].'</h5>'
if (
file_exists($path)){?> 
<img src="<? echo $path?>" alt="Portada" width="50"  height="50" hspace="10" vspace="3" border="0" align="right">; 
<? };?> 
<? 
echo '<p valign=top style=color:#a000000; font-size:14px; font-family:Tahoma, Verdana; text-decoration:none>'.$row['ampliada'].'<br><br><strong style=color:#FF4A4A; font-size:14px; font-family:Tahoma, Verdana; text-decoration:none>'.$row['fuente'].'</strong>';} ?> 
   </td> 
  </tr> 
</table> 
<?
}
mysql_free_result($result); 
mysql_close($connect);?>
aver si esto te resulta
__________________
Diseñador Gráfico / Programador PHP / Cisco Certified Network Associate (CCNA) / CSS / Java Scripting / SQL / C-Scripting / Entre otros...

:cool:
BOX
  #4 (permalink)  
Antiguo 12/11/2005, 17:58
Avatar de Seppo  
Fecha de Ingreso: marzo-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.284
Antigüedad: 19 años, 1 mes
Puntos: 17
Además de las correcciones de PHP que te hicieron, me parece que empezar $path con "/" es un error, que deberías poner $path = "img/secciones..."

Por otro lado, sino te pone error y no te carga la imagen, poné propiedades sobre la imagen y fijate la ruta del archivo. Si no entra al if, yo deshabilitaría el if para forzar a que aparezca y ahí comprobaría la ruta.

Suerte
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:28.