Código 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"] == "editor")) {
$insertSQL = sprintf("INSERT INTO post (titulo_post, post, data_time, username, juego, categorias) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['texto'], "text"),
GetSQLValueString($_POST['data_time'], "date"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['selec'], "text"),
GetSQLValueString($_POST['categorias'], "text"));
mysql_select_db($database_coneccion, $coneccion);
$Result1 = mysql_query($insertSQL, $coneccion) or die(error());
$insertGoTo = "posteado.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header("Location: posteado.php");
//header(sprintf("Location: %s", $insertGoTo));
}
$maxRows_Recordset1 = 100;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_coneccion, $coneccion);
$query_Recordset1 = "SELECT * FROM post ORDER BY id_post DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $coneccion) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
mysql_select_db($database_coneccion, $coneccion);
$query_nombre_del_juego = "SELECT * FROM `admin`";
$nombre_del_juego = mysql_query($query_nombre_del_juego, $coneccion) or die(mysql_error());
$row_nombre_del_juego = mysql_fetch_assoc($nombre_del_juego);
$totalRows_nombre_del_juego = mysql_num_rows($nombre_del_juego);