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

    Inserimento date con DW

    Buonasera a tutti

    Ho un problema con DW e PHP.
    Devo fare un sito velocissimo, ho un db con una tabella con 4 colonne, data, titolo, testo e inserimento rispettivamente datetime, varchar(50) e varchar(500) e ancora datetime.
    dato che sono completamente a secco di PHP sto usando dreamweaver a pieno regime (e me ne vergogno un sacco, ma non ho tempo per mettermi a studiare al momento), ma ho un problema, inserisco i campi di testo correttamente ma mi setta le date sempre a 0...
    posto paro paro il codice che (ahimè) genera dreamweaver
    Codice PHP:
    <?php
    if (!function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $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;
    }
    }

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

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      
    $insertSQL sprintf("INSERT INTO tbl_elementi (dato_data, dato_txt, dato_tipo, dato_ins) VALUES (%s, %s, %s, %s)",
                           
    GetSQLValueString($_POST['dato_data'], "date"),
                           
    GetSQLValueString($_POST['dato_txt'], "text"),
                           
    GetSQLValueString($_POST['dato_tipo'], "text"),
                           
    GetSQLValueString($_POST['dato_ins'], "date"));

      
    mysql_select_db($database_conn_prova$conn_prova);
      
    $Result1 mysql_query($insertSQL$conn_prova) or die(mysql_error());

      
    $insertGoTo "index.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo));
    }
    ?>
    grazie in anticipo!

  2. #2
    Il problema di DW sta, generalmente, nella connessione al database.

    La prima riga, con buona probabilità, è quella che ti include la connessione:
    Codice PHP:
    virtual ('Connections/tuoNomeConnessione.php'); 
    Generalmente è qui il problema.
    Prova a sostituire con:
    Codice PHP:
    require_once('../Connections/tuoNomeConnessione.php'); 
    Inoltre, dopo
    Codice PHP:
    header(sprintf("Location: %s"$insertGoTo)); 
    piazzagli un bel
    Codice PHP:
    exit; 
    In questo modo dovrebbe funzionare

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.