Código 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 noticias (id, categoria, titulo, imagen, ruta, resumen, contenido, escritor, `date`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['categoria'], "text"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['imagen'], "text"),
GetSQLValueString($_POST['ruta'], "text"),
GetSQLValueString($_POST['resumen'], "text"),
GetSQLValueString($_POST['contenido'], "text"),
GetSQLValueString($_POST['escritor'], "text"),
GetSQLValueString($_POST['date'], "date"));
mysql_select_db($database_portadas, $portadas);
$Result1 = mysql_query($insertSQL, $portadas) or die(mysql_error());
$insertGoTo = "notas.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_portadas, $portadas);
$query_ultimas = "SELECT * FROM noticias";
$ultimas = mysql_query($query_ultimas, $portadas) or die(mysql_error());
$row_ultimas = mysql_fetch_assoc($ultimas);
$totalRows_ultimas = mysql_num_rows($ultimas);
?>
Lo que quiero es que en vez de agarrar la ruta del formulario
me inserte el valor que tiene ".$_FILES['fichero']['name']." que es el archivo que subi con el formulario anterio... alguien sabe que puedo hacer
$insertSQL = sprintf("INSERT INTO noticias (id, categoria, titulo, imagen, ruta, resumen, contenido, escritor, `date`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['categoria'], "text"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['imagen'], "text"),
GetSQLValueString($_POST['ruta'], "text"),
GetSQLValueString($_POST['resumen'], "text"),
GetSQLValueString($_POST['contenido'], "text"),
GetSQLValueString($_POST['escritor'], "text"),
GetSQLValueString($_POST['date'], "date"));