con l'upload ho risolto diversamente grazie mille soloche adesso non capisco perchèla query che prima funzionava perfettamente adesso da
Query was empty
:master:
codice:
<?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"] == "form1")) {
//VARIABILI IMPOSTABILI DALL'UTENTE
$uppath = "C:\AppServ\www\universita\img\imaginemenu"; //PATH DOVE VERRANNO UPLOADDATI GLI AVATAR
$dimlim = "si"; //LIMITE DI DIMENSIONE [si o no]
$formatolim = "si"; //LIMITE DI FORMATO [si o no]
$size = $_POST['size']; //LIMITE DI DIMESIONE
$larg= $_POST['larg']; //LIMITE LARGHEZZA
$alte= $_POST['alte']; //LIMITE ALTEZZA
//Tutti i tipi di imagini
$tipo1 = "image/pjpeg"; //Jpeg type 1
$tipo2 = "image/jpeg"; //Jpeg type 2
$tipo3 = "image/gif"; //Gif type
$tipo4 = "image/png"; //Png type
$tipo5 = "image/bmp"; //Bmp Type
$log = "";
//INIZIO UPLOAD
//CONTROLLA SE LA STRINGA E' VUOTA
if ($img1_name == "")
{
$log .= "Nessun file selezionato per l'upload
";
}
if ($img1_name != "")
{
//CONTROLLA SE IL FILE E' GIA' ESISTENTE
if (file_exists("$uppath/$img1_name"))
{
$log .= "Il File esiste già
";
}
else
{
//CONTROLLA LA DIMEZIONE DEL FILE
$errore=0;
if ($dimlim == "si")
{
if ($img1_size > $size)
{
$errore=1;
$log .= "Il file è troppo grande! Non deve superare i $size byte
";
}
}
//CONTROLLA IL FORMATO DELL'IMMAGINE
if ($formatolim == "si")
{
list($width, $height) = @getimagesize($img1);
if(($width>$larg)or($height>$alte))
{
$errore=1;
$log .= "Il formato dell'immagine è più grande del limite $larg x $alte";
}
}
if ($errore==0)
{
//CONTROLLA SE IL FILE E' UNA IMMAGINE
if (($img1_type == $tipo1) or ($img1_type == $tipo2) or ($img1_type == $tipo3) or ($img1_type == $tipo4) or ($img1_type == $tipo5))
{
@copy($img1, "$uppath/$img1_name") or $log .= "Impossibile copiare l'immagine nel server
";
if (file_exists("$uppath/$img1_name"))
{
$log .= "Immagine uploaddata
";
$insertSQL = sprintf("INSERT INTO docenti (nome, descrizione, curriculum, foto) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['descrizione'], "text"),
GetSQLValueString($_POST['curriculum'], "text"),
GetSQLValueString($_POST['foto'], "text"));
}
}
else
{
$log .= "Il file scelto non è una immagine [$tipo2, $tipo3, $tipo4 o $tipo5]
";
}
}
}
}
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
$insertGoTo = "../success.php?cosa=DOCENTE%20INSERITO%20CON%20SUCCESSO!";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>