Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2005
    Messaggi
    31

    comandi insert e update

    Ciao a tutti io ho questo codice
    Codice PHP:
    <?php include './page.php';   HtmlHeader(); Navigation();   $message ""; if (isset($_GET['alert'])) {     if ($_GET['alert'] == 0)     {         $message "Dati scritti correttamente nel database";     }       if ($_GET['alert'] == 1)     {         $message "ERRORE: Nessun dato scritto nel database.
    Campo NOME deve essere compilato!"
    ;     }   }   echo "

    "
    ; echo $message;   ?> <table> 
     
     <form action="insert_data.php" method="POST"> <tr> <td>Nome</td> <td> <input type="text" maxlength="10" name="nome" />
    </td</tr> <tr> <td>Gen</td> <td> <input type="text" maxlength="1" name="gen" />
    </td></tr> <tr> <td>Feb</td> <td> <input type="text" maxlength="1" name="feb" />
    </td></tr> <tr> <td>Mar</td> <td> <input type="text" maxlength="1" name="mar" />
    </td></tr> <tr> <td>Apr</td> <td> <input type="text" maxlength="1" name="apr" />
    </td></tr> <tr> <td>Mag</td> <td> <input type="text" maxlength="1" name="mag" />
    </td></tr> <tr> <td>Giu</td> <td> <input type="text" maxlength="1" name="giu" />
    </td></tr> <tr> <td>Lug</td> <td> <input type="text" maxlength="1" name="lug" />
    </td></tr> <tr> <td>Ago</td> <td> <input type="text" maxlength="1" name="ago" />
    </td></tr> <tr> <td>Set</td> <td> <input type="text" maxlength="1" name="set" />
    </td></tr> <tr> <td>Ott</td> <td> <input type="text" maxlength="1" name="ott" />
    </td></tr> <tr> <td>Nov</td> <td> <input type="text" maxlength="1" name="nov" />
    </td></tr> <tr> <td>Dic</td> <td> <input type="text" maxlength="1" name="dic" />
    </td></tr> <tr><td>
     <input type="submit" value="inserisci" /></td</tr> </form> </table>  <?php   HtmlFooter();   ?>
    nella pagine insert.php
    e questo codice
    Codice PHP:
    <?php     if (empty($_POST['nome']) ) {     header("Location: insert.php?alert=1");     die; }   include "./connect.php";   $sql "INSERT INTO telematici (nome,gen,feb,mar,apr,mag,giu,lug,ago) VALUES ('$_POST[nome]','$_POST[gen]','$_POST[feb]','$_POST[mar]','$_POST[apr]','$_POST[mag]','$_POST[giu]','$_POST[lug]','$_POST[ago]')";    mysql_query($sql$conn);   header("Location: insert.php?alert=0");   ?>
    nella pagina insert_data.php

    il mio problema e' che se nella pagina insert_data.php aggiungo nella riga del INSERTO INTO altri valori non inserisce piu' nessun dato, cosa che fa con il codice che ho postato, la stessa cosa me lo fa con il comdando UPDATE. Ci sono limitazioni per questi due comandi?

  2. #2
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,452
    Edita il messaggio e metti un'istruzione per riga, così non si capisce niente.

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2005
    Messaggi
    31
    scusate, riposto il codice

    questo e' il file insert_data.php

    Codice PHP:
    <?php if (empty($_POST['nome']) )
    {
    header("Location: insert.php?alert=1");
    die;
    }
    include 
    "./connect.php";
    $sql "INSERT INTO telematici (nome,gen,feb,mar,apr,mag,giu,lug,ago) VALUES ('$_POST[nome]','$_POST[gen]','$_POST[feb]','$_POST[mar]','$_POST[apr]','$_POST[mag]','$_POST[giu]','$_POST[lug]','$_POST[ago]')";
    mysql_query($sql$conn);
    header("Location: insert.php?alert=0");
    ?>
    Codice PHP:
    <?php include './page.php';
    HtmlHeader();
    Navigation();
    $message "";
    if (isset(
    $_GET['alert']))
    {
    if (
    $_GET['alert'] == 0)
    {
    $message "Dati scritti correttamente nel database";
    }
    if (
    $_GET['alert'] == 1)
    {
    $message "ERRORE: Nessun dato scritto nel database.
    Campo NOME deve essere compilato!"
    ;
    }
    }
    echo 
    "

    "
    ;
    echo 
    $message;
    ?>
    <table> 
     

    <form action="insert_data.php" method="POST"> <tr> <td>Nome</td> <td>
    <input type="text" maxlength="10" name="nome" />
    </td</tr> <tr> <td>Gen</td> <td> <input type="text" maxlength="1" name="gen" />
    </td></tr> <tr> <td>Feb</td> <td> <input type="text" maxlength="1" name="feb" />
    </td></tr> <tr> <td>Mar</td> <td> <input type="text" maxlength="1" name="mar" />
    </td></tr> <tr> <td>Apr</td> <td> <input type="text" maxlength="1" name="apr" />
    </td></tr> <tr> <td>Mag</td> <td> <input type="text" maxlength="1" name="mag" />
    </td></tr> <tr> <td>Giu</td> <td> <input type="text" maxlength="1" name="giu" />
    </td></tr> <tr> <td>Lug</td> <td> <input type="text" maxlength="1" name="lug" />
    </td></tr> <tr> <td>Ago</td> <td> <input type="text" maxlength="1" name="ago" />
    </td></tr> <tr> <td>Set</td> <td> <input type="text" maxlength="1" name="set" />
    </td></tr> <tr> <td>Ott</td> <td> <input type="text" maxlength="1" name="ott" />
    </td></tr> <tr> <td>Nov</td> <td> <input type="text" maxlength="1" name="nov" />
    </td></tr> <tr> <td>Dic</td> <td> <input type="text" maxlength="1" name="dic" />
    </td></tr> <tr><td>

    <input type="submit" value="inserisci" /></td</tr> </form> </table>
    <?php
    HtmlFooter
    ();
    ?>
    e questo e' il file insert.php

  4. #4
    Originariamente inviato da gotiche
    scusate, riposto il codice

    questo e' il file insert_data.php

    Codice PHP:
    <?php if (empty($_POST['nome']) )
    {
    header("Location: insert.php?alert=1");
    die;
    }
    include 
    "./connect.php";
    $sql "INSERT INTO telematici (nome,gen,feb,mar,apr,mag,giu,lug,ago) VALUES ('$_POST[nome]','$_POST[gen]','$_POST[feb]','$_POST[mar]','$_POST[apr]','$_POST[mag]','$_POST[giu]','$_POST[lug]','$_POST[ago]')";
    mysql_query($sql$conn);
    header("Location: insert.php?alert=0");
    ?>
    Codice PHP:
    <?php include './page.php';
    HtmlHeader();
    Navigation();
    $message "";
    if (isset(
    $_GET['alert']))
    {
    if (
    $_GET['alert'] == 0)
    {
    $message "Dati scritti correttamente nel database";
    }
    if (
    $_GET['alert'] == 1)
    {
    $message "ERRORE: Nessun dato scritto nel database.
    Campo NOME deve essere compilato!"
    ;
    }
    }
    echo 
    "

    "
    ;
    echo 
    $message;
    ?>
    <table> 
     

    <form action="insert_data.php" method="POST"> <tr> <td>Nome</td> <td>
    <input type="text" maxlength="10" name="nome" />
    </td</tr> <tr> <td>Gen</td> <td> <input type="text" maxlength="1" name="gen" />
    </td></tr> <tr> <td>Feb</td> <td> <input type="text" maxlength="1" name="feb" />
    </td></tr> <tr> <td>Mar</td> <td> <input type="text" maxlength="1" name="mar" />
    </td></tr> <tr> <td>Apr</td> <td> <input type="text" maxlength="1" name="apr" />
    </td></tr> <tr> <td>Mag</td> <td> <input type="text" maxlength="1" name="mag" />
    </td></tr> <tr> <td>Giu</td> <td> <input type="text" maxlength="1" name="giu" />
    </td></tr> <tr> <td>Lug</td> <td> <input type="text" maxlength="1" name="lug" />
    </td></tr> <tr> <td>Ago</td> <td> <input type="text" maxlength="1" name="ago" />
    </td></tr> <tr> <td>Set</td> <td> <input type="text" maxlength="1" name="set" />
    </td></tr> <tr> <td>Ott</td> <td> <input type="text" maxlength="1" name="ott" />
    </td></tr> <tr> <td>Nov</td> <td> <input type="text" maxlength="1" name="nov" />
    </td></tr> <tr> <td>Dic</td> <td> <input type="text" maxlength="1" name="dic" />
    </td></tr> <tr><td>

    <input type="submit" value="inserisci" /></td</tr> </form> </table>
    <?php
    HtmlFooter
    ();
    ?>
    e questo e' il file insert.php
    iserisci un
    echo $sql;

    così vedi cosa ti restituisce

    per me l'errore è nella sintassi che viene creata

    ciao

  5. #5
    Utente di HTML.it
    Registrato dal
    May 2005
    Messaggi
    31
    Originariamente inviato da mansportivo
    iserisci un
    echo $sql;

    così vedi cosa ti restituisce

    per me l'errore è nella sintassi che viene creata

    ciao
    ho inserito nel file modify_data, e' corretto? e dove dici di inserirlo? comunque in ogni parte lo metto non dice nulla..

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2005
    Messaggi
    31
    ho provato a mettere ott invece di set e funziona, a questo punto credo sia la parola set che non accetta...

  7. #7
    Di sicuro la parola SET in SQL ha una sua valenza specifica.

    Prova a cambiare il nome del campo! Metti tipo settem

  8. #8
    Utente di HTML.it
    Registrato dal
    May 2005
    Messaggi
    31
    Originariamente inviato da Samleo
    Di sicuro la parola SET in SQL ha una sua valenza specifica.

    Prova a cambiare il nome del campo! Metti tipo settem
    già provato ma niente e neanche con settembre. Ho metto ago1 e morta la. Grazie a tutti!

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 © 2024 vBulletin Solutions, Inc. All rights reserved.