PDA

View Full Version : [php] visualizzare immagini dal database


brianss
06-08-2008, 18:09
ciao ragazzi...ho un file img.php che connettendosi al database dovrebbe estrarre l'immagine jpeg da DB e visualizzarla quando viene chiamato


include("include/config.php")

$id = $_GET['id'];

$sql = "SELECT data, ext FROM accordi WHERE id=".$id;
$query = mysql_query($sql, $conn) or die("niente query");


$valori = mysql_fetch_object($query) ;


header("Content-type: $valori->ext");

//invio limg
echo $valori->data;



però quando lo richiamo con <img src="img.php" /> non visualizza nulla....
sapete scovare l'errore?

DrZoidberg
28-08-2008, 11:17
L'attributo src del tag <img> vuole l'URL di una foto....te invece gli passi l'URL di una pagina PHP...normale ke nn visualizza niente!!!!
la sintassi giusta è <img src="nome_foto.jpg">....non <img src="img.php" /> !!!

brianss
28-08-2008, 12:22
se la risposta fosse stata così semplice ti pare che scrivevo qua??

se il file php ha il compito di elaborare e visualizzare immagini allora nell'attributo src puoi mettere anche dei file php, si fa con i captcha ad esempio

vizzz
28-08-2008, 13:11
testa lo script invocandolo a mano e vedi se l'echo dei dati è giusto

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.