Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    163

    Problemi visualizzazione file caricato sul DB

    Buongionro,

    come da oggetto, non riesco a visualizzare il file che carico sul mio db.
    La funzionalita che vorrei implemetare è un box di ricerca foto e visualizzazione selezionando da 2 menu a tendina.
    Premettendo che sono pienamente in alta marea sul php...

    download_file.php


    <?php
    $host = "localhost"; //nome dell'host, in locale con xampp è questo
    $user = "root"; //di default mysql usa questo, se l'hai cambiato metti il tuo
    $pass = ""; //di default mysql non ha la password settata, se l'hai impostata scrivila qui
    $dbname = "test"; //il nome che hai dato al database
    $conn = mysql_connect($host, $user, $pass) or die('Impossibile stabilire una connessione col database: ' . mysql_error());
    mysql_select_db($dbname,$conn) or die('Impossibile selezionare il database: ' . mysql_error());




    Sono in disperazione...Grazie a tutti!




    $Categoria=$_POST["Categoria"];
    $Citta=$_POST["Citta"];
    // ESEGUIAMO LA QUERY DI INSERIMENTO
    $result = @mysql_query("SELECT foto FROM foto WHERE Categoria = '".$Categoria."' AND Citta = '".$Citta."'") // SELEZIONA FOTO
    or die("Errore sql : " .mysql_error());

    echo $result;
    while ($row = mysql_fetch_assoc($result)){
    echo $row['NomeFile'];
    }
    // CHIUDIAMO LA CONNESSIONE A MYSQL
    @mysql_close();


    ?>


    <html>
    <body>
    <?php
    header('Content-Length: '.strlen($result));
    header("Content-type: image/jpeg");
    // outputing image
    echo $result;
    exit();
    ?>
    </body>
    </html>



    cerca.php

    <?php





    $host = "localhost"; //nome dell'host, in locale con xampp è questo
    $user = "root"; //di default mysql usa questo, se l'hai cambiato metti il tuo
    $pass = ""; //di default mysql non ha la password settata, se l'hai impostata scrivila qui
    $dbname = "test"; //il nome che hai dato al database
    $conn = mysql_connect($host, $user, $pass) or die('Impossibile stabilire una connessione col database: ' . mysql_error());
    mysql_select_db($dbname,$conn) or die('Impossibile selezionare il database: ' . mysql_error());

    $queryCitta = "SELECT Citta FROM Lazio";
    $queryCategoria ="SELECT ID,DESCRIZIONE FROM Categoria";


    $resultCitta = mysql_query($queryCitta) or die (mysql_error());
    $resultCategoria = mysql_query($queryCategoria) or die (mysql_error());








    // CHIUDIAMO LA CONNESSIONE A MYSQL
    @mysql_close();

    ?>



    <html>
    <head>
    <title>Form per l'inserimento</title>
    </head>
    <body>

    <form enctype="multipart/form-data" action="download_file.php" method="post">
    Citta
    <select name="Citta" >
    <?php

    while ($row = mysql_fetch_array($resultCitta, MYSQL_NUM)) {
    echo "<option value=\"".$row[0]."\">".$row[0]."</option>";
    }

    ?>

    </select>


    Categoria
    <select name="Categoria" >
    <?php

    while ($row = mysql_fetch_array($resultCategoria, MYSQL_NUM)) {
    echo "<option value=\"".$row[0]."\">".$row[1]."</option>";
    }

    ?>
    </select>


    <input type="submit" name="Scarica" value="Download" />
    </form>





    </body>
    </html>

  2. #2
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    il file è salvato su un BLOB, non si capisce bene cosa stai facendo
    poi devi mettere il tuo codice fra i tag php che almeno viiene + leggibile

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    163
    Si è stato salvato su un BLOB, in che senso devo mettere in tag?

    Ho incollato direttamente i tag per visualizzare...

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    163
    Praticamente il messaggio d'errore è :
    Resource id #3
    Warning: strlen() expects parameter 1 to be string, resource given in C:\xampp\xampp\htdocs\Dowload Volantino\V1 del 07 09 10\download_file.php on line 34

    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\xampp\htdocs\Dowload Volantino\V1 del 07 09 10\download_file.php:2) in C:\xampp\xampp\htdocs\Dowload Volantino\V1 del 07 09 10\download_file.php on line 34

    Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\xampp\htdocs\Dowload Volantino\V1 del 07 09 10\download_file.php:2) in C:\xampp\xampp\htdocs\Dowload Volantino\V1 del 07 09 10\download_file.php on line 35
    Resource id #3


    Qualcuno sa darmi qualche dritta?


    Grazie a ttt

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.