inserire immagine con dreamweaver INSERT

  • Creatore Discussione Creatore Discussione dovito
  • Data di inizio Data di inizio

dovito

Nuovo Utente
30 Nov 2008
1
0
0
Salve a tutti, sono nuovo e non capisco grand ke di php. Ho scelto Dreamweaver perche genera codici php automaticamente con pocchi sforzi.
Vorrei inserire delle immagine nel db o in un directory sul server in modo da poter fare un link all'immagine con descrizione in una pagina. un esempio come inserire utente con immagine e descrizione. Vado al punto con mio codice. AIUTO!!!!!!!!!

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 = $_FILES['userfile'];
$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 photo (`size`, immagine, nome, type) VALUES (','{$size['mime']}', '{$immagine}','{$size[3]}','{$_FILES['userfile']['name']}')",
GetSQLValueString($_POST['size'], "text"),
GetSQLValueString($_POST['immagine'], "text"));

mysql_select_db($database_eurocar, $eurocar);
$Result1 = mysql_query($insertSQL, $eurocar) or die(mysql_error());
}
?>
 
Ultima modifica:

Discussioni simili