Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    [PHP]Tabella con dati mysql e invio

    Ho realizzato una tabella per modificare i dati in un database mysql ma quando invio i dati mi dice errore.
    questa è la pagina da dove vengono inviati i dati
    Codice PHP:
    <?php require_once('Connections/orario.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      if (
    PHP_VERSION 6) {
        
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    mysql_select_db($database_orario$orario);
    $query_classe1a "SELECT * FROM `1a`";
    $classe1a mysql_query($query_classe1a$orario) or die(mysql_error());
    $row_classe1a mysql_fetch_assoc($classe1a);
    $totalRows_classe1a mysql_num_rows($classe1a);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Documento senza titolo</title>
    </head>

    <body>
    <form action="inviodati.php" method="post">
    <table width="100%" border="1">
      <tr>
        <td>ID</td>
        <td>Giorno</td>
        <td>1ora</td>
        <td>2ora</td>
        <td>3ora</td>
        <td>4ora</td>
        <td>5ora</td>
        <td></td>
      </tr>
      <tr>
        <td><label for="testo_id"></label>
          <input value="<?php echo $row_classe1a['ID']; ?>" type="text" name="testo_id" id="testo_id" /></td>
        <td><label for="testo_giorno"></label>
          <input value="<?php echo $row_classe1a['giorno']; ?>" type="text" name="testo_giorno" id="testo_giorno" /></td>
        <td><label for="testo_1ora"></label>
          <input value="<?php echo $row_classe1a['mat1ora']; ?>" type="text" name="testo_1ora" id="testo_1ora" /></td>
        <td><label for="testo_2ora"></label>
          <input value="<?php echo $row_classe1a['mat2ora']; ?>" type="text" name="testo_2ora" id="testo_2ora" /></td>
        <td><label for="testo_3ora"></label>
          <input value="<?php echo $row_classe1a['mat3ora']; ?>" type="text" name="testo_3ora" id="testo_3ora" /></td>
        <td><label for="testo_4ora"></label>
          <input value="<?php echo $row_classe1a['mat4ora']; ?>" type="text" name="testo_4ora" id="testo_4ora" /></td>
        <td><label for="testo_5ora"></label>
          <input value="<?php echo $row_classe1a['mat5ora']; ?>" type="text" name="testo_5ora" id="testo_5ora" /></td>
        <td><input type="submit" name="puls" id="puls" value="Invia" /></td>
      </tr>
    </table>
    </form>


    </p>
    </body>
    </html>
    <?php
    mysql_free_result
    ($classe1a);
    ?>
    e questa è la pagina per l'ivio
    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Documento senza titolo</title>
    </head>
    <?php


    include "Connections/orario.php";
    $ID =$_POST["testo_id"];
    $giorno =$_POST["testo_giorno"];
    $mat1ora =$_POST["testo_1ora"];
    $mat2ora =$_POST["testo_2ora"];
    $mat3ora =$_POST["testo_3ora"];
    $mat4ora =$_POST["testo_4ora"];
    $mat5ora =$_POST["testo_5ora"];

    echo 
    "$cognome";
    echo 
    "$nome";
    echo 
    "$e_mail";
    echo 
    "$societ";
    echo 
    "$gruppo";
    echo 
    "$user";
    echo 
    "$password";


    $query "INSERT INTO 1a (`ID`, `giorno`, `mat1ora`, `mat2ora`, `mat3ora`, `mat4ora`, `mat5ora`) VALUES ('$testo_id','$testo_giorno','$testo_1ora','$testo_2ora','$testo_3ora','$testo_4ora','$testo_5ora')";
    echo 
    "$query";
    echo 
    "$conn";
    $result mysql_query($query,$conn);
    echo 
    "$result";
    if (
    $result == FALSE)
    {
    echo (
    "inserimento nn riuscito");
    }
    else
    {
    echo (
    "inserimento riuscito");
    }

    ?> 
    <body>
    </body>
    </html>

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    posta la query generata (vedo che già la stampi a video)...

  3. #3
    questa è la query che mi esce
    codice:
    INSERT INTO 1a (`ID`, `giorno`, 'mat1ora', mat2ora`, `mat3ora`, `mat4ora`, `mat5ora`) VALUES ('','','','','','','')inserimento nn riuscito

  4. #4
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    nella query postata ci sono errori con gli apici... aggiungi cmq anche una stampa di mysql_error() per vedere l'errore esatto... puoi anche "copia&incollare" la query su un'interfaccia del db (es. phpmyadmin) e vedere lì l'errore

  5. #5
    dove ci sono gli errori di apici?
    Come faccio a stampare l'errore di mysql?
    la query lo presa proprio da phpmyadmin

  6. #6
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    prima di "mat2ora" non c'è l'apice di apertura e inoltre sono mischiati due tipi di apici diversi (si nota infatti che alcuni sono graficamente inclinati, altri no): in PHP usa solo quelli "normali"... per l'errore usa mysql_error()

  7. #7
    sono un novizio, ma non mi de nessun errore

  8. #8
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    modifica echo ("inserimento nn riuscito"); con echo ("inserimento nn riuscito ".mysql_error());

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.