Visualizzazione dei risultati da 1 a 7 su 7

Discussione: problemi scrittura DB

  1. #1

    problemi scrittura DB

    Salve ragazzi,
    è la prima volta che uso PHP.

    Vorrei scrivere su un database tramite un form contenente 3 campi.

    Sul DB succede che "scrivo" ma scrivo sempre 0

    qlc potrebbe aiutarmi? qualche impostazione del server sql?

    la pagina la si può vedere al seguente indirizzo:
    QUI
    Per scrivere invece Qui


    Grazie mille in anticipo per l'aiuto.

    Saluti

  2. #2
    Senza codice come si fa ad individuare il problema?
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  3. #3
    Originariamente inviato da satifal
    Senza codice come si fa ad individuare il problema?
    Sorry

    Inserimento dati

    Codice PHP:
    <?php require_once('Connections/man.php'); ?>
    <?php
    function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "ins_man")) {
      
    $insertSQL sprintf("INSERT INTO manifesto (Nome, Cognome, Professione) VALUES (%s, %s, %s)",
                           
    GetSQLValueString($_POST['Nome'], "int"),
                           
    GetSQLValueString($_POST['cognome'], "int"),
                           
    GetSQLValueString($_POST['professione'], "int"));

      
    mysql_select_db($database_man$man);
      
    $Result1 mysql_query($insertSQL$man) or die(mysql_error());
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>

    <div align="center">
      <form action="<?php echo $editFormAction?>" method="POST" name="ins_man" id="ins_man">
        <div align="left">
          

    Nome:
            <input name="Nome" type="text" id="Nome">
    </p>
          

    Cognome: 
            <input name="cognome" type="text" id="cognome"> 
          </p>
          

    Professione*: 
            <input name="professione" type="text" id="professione"> 
          </p>
          


            <input type="submit" name="Submit" value="Supporta Marco Stella">
          </p>
        </div>
        <input type="hidden" name="MM_insert" value="ins_man">
      </form>
    </div>
    </body>
    </html>
    Lettura da database

    Codice PHP:
    <?php require_once('Connections/man.php'); ?>
    <?php
    mysql_select_db
    ($database_man$man);
    $query_man "SELECT Nome, Cognome, Professione FROM manifesto";
    $man mysql_query($query_man$man) or die(mysql_error());
    $row_man mysql_fetch_assoc($man);
    $totalRows_man mysql_num_rows($man);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <div align="center">
      <?php do { ?>
      <?php echo $row_man['Nome']; ?> <?php echo $row_man['Cognome']; ?> <?php echo $row_man['Professione']; ?>,
      <?php } while ($row_man mysql_fetch_assoc($man)); ?>
    </div>
    </body>
    </html>
    <?php
    mysql_free_result
    ($man);
    ?>

    Grazie mille

  4. #4
    Fai un echo di $insertSQL prima di eseguirla.
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  5. #5
    Originariamente inviato da satifal
    Fai un echo di $insertSQL prima di eseguirla.
    ummm è qualcosa che si mangia?

    delucidazioni... :P

    so pivello

    grazie mille

  6. #6
    Codice PHP:
    ...
    echo 
    $insertSQL;
    mysql_select_db($database_man$man);
    $Result1 mysql_query($insertSQL$man) or die(mysql_error()); 
    ... 
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  7. #7
    Grazie mille!!!

    Risolto!

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.