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!