Visualizzazione dei risultati da 1 a 3 su 3

Discussione: could not connect

  1. #1

    could not connect

    ho questo form per inserire dei dati + un'immagine nel database.. ma al momento dell'invio mi dice "could not connect."
    eppure è tutto corretto!
    come mai?



    <?php
    include('function/config.inc');
    session_start();

    $flag = $_POST['flag'];
    $nome = $_POST['nome'];
    $descrizione = $_POST['descrizione'];


    if (is_uploaded_file($_FILES['foto']['tmp_name'])) {

    $foto = "/var.../".$_FILES['foto']['name']; //('/var.../immagine.jpg')
    move_uploaded_file($_FILES['foto']['tmp_name'],$foto);
    }
    else { $foto = ""; }

    if ($flag == 99) {

    $query="INSERT INTO jobs (nome,descrizione,foto) VALUES ('$nome','$descrizione','$foto')";

    // echo "QUERY INSERIMENTO: ".$query;

    mysql_query($query,$connessione) or die('Could not connect:' .mysql_error());

    echo "inserimento avvenuto con successo!";

    }


    ?>



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>

    <title>Inserisci app!</title>
    </head>
    <body>
    <center>
    <h1>Inserisci app!</h1>




    <form action="inserisci_app.php" method="post" style="border: medium solid red;"class="modulo" enctype="multipart/form-data">
    <input type="hidden" name="flag" value="99">
    <table border="0" cellspacing="5" cellpadding="6" width="350">
    <tr>
    <td width="150">Nome:</td>
    <td width="200"><input type="text" name="nome"></td>
    </tr>
    <tr>
    <td width="150">Descrizione:</td>
    <td width="200"><input type="text" name="descrizione"></td>
    </tr>


    <tr>
    <td width="150">Foto:</td>
    <td width="200"><input type="file" name="foto"></td>
    </tr>


    <tr>
    <td width="150"><input type="reset" value="Svuota Modulo"></td>
    <td width="200"><input type="submit" name="submit" value="Inserisci"></td>
    </tr>
    </table>
    </form>

    </center>
    </body>
    <?php
    mysql_close($connessione);
    ?>
    </html>

  2. #2
    in base a ciò che hai postato l'errore può dipendere:
    1) connessione non effettuata;
    2) query errata: tabella non esistente o campi non esistenti (oppure con nomi errati)

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    356
    Ciao,
    a meno che la connessione al db non venga fatta nel file incluso function/config.inc, l'errore è questo: non hai effettuato la connessione e alla funzione per fare la query passi una variabile inesistente!

    Se invece il problema non è questo, prova a darci qualche notizia in più: per esempio la struttura della tabella e come gestisci il tipo di dato per "foto".

    Ciao ciao
    Jekkil

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.