Código PHP:
<?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")) {
$insertSQL = sprintf("INSERT INTO contenido (id, titulo, fecha, intro, foto, texto, categoria_id) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['intro'], "text"),
GetSQLValueString($_POST['foto'], "text"),
GetSQLValueString($_POST['texto'], "text"),
GetSQLValueString($_POST['categoria_id'], "int"));
mysql_select_db($database_ctneditor, $ctneditor);
$Result1 = mysql_query($insertSQL, $ctneditor) or die(mysql_error());
$insertGoTo = "insertado.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_ctneditor, $ctneditor);
$query_getcat = "SELECT * FROM categorias";
$getcat = mysql_query($query_getcat, $ctneditor) or die(mysql_error());
$row_getcat = mysql_fetch_assoc($getcat);
$totalRows_getcat = mysql_num_rows($getcat);
?>[/B]
Este es el insert q tengo, o si algiuien me dice como inserta la foto y q sea la adecuada con el contenido...