Saludos muchachos, ando haciendo un sistema de ingreso de productos y por primera vez me topo con este error...
Warning: sprintf() [function.sprintf]: Argument number must be greater than zero. in C:\xampp\htdocs\albarracin\html\admin\ing_prod.php on line 55
Query was empty
Alguien podria ver mi error???
Código PHP:
<?php require_once('../Connections/alba.php'); ?>
<?php
include_once("fckeditor/fckeditor.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 . "'" : "''";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "''";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "''";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "''";
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")) {
$ediciondir= '../galeria/';
$uploaddir=$ediciondir;
if (!is_dir($ediciondir)) { mkdir($uploaddir, 0777); }
move_uploaded_file($_FILES['imgprinc']['tmp_name'], $uploaddir . $_FILES['imgprinc']['name']);
$filename = $_FILES['imgprinc']['name'];
$insertSQL = sprintf("INSERT INTO productos (id, id_cat, titulo, descripcion, metraje, pecio, imgprinc) VALUES (%s, %$, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['id_cat'], "text"),
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['metraje'], "text"),
GetSQLValueString($_POST['pecio'], "text"),
GetSQLValueString($filename, "text"));//linea55
mysql_select_db($database_alba, $alba);
$Result1 = mysql_query($insertSQL, $alba) or die(mysql_error());
$insertGoTo = "list_prod.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_alba, $alba);
$query_Recordset1 = "SELECT * FROM categoria";
$Recordset1 = mysql_query($query_Recordset1, $alba) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Panel Administrativo</title>
<script language="javascript" type="text/javascript">
function validar_archivo(archivo) {
var error_archivo;
error_archivo=0;
var file=archivo.value;
if (file=="")
{ error_archivo=1; }
//texto += "\n\nIngrese Foto"
else{
// file=document.formulario.FOTO.value
extArray = new Array(".gif",".jpg",".swf");
// Extension de archivos permitidos
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i=0; i < extArray.length; i++){
if (extArray[i] == ext){
allowSubmit = true;
break;
}
}
if (!allowSubmit) {
error_archivo=2;
// texto += "\n\nFOTO: solo admite archivo con la extensión ''gif, .jpeg , .jpg''";
}
}
return error_archivo;
}
</script>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style></head>
<body>
<table width="449" border="0" align="center" cellpadding="0" cellspacing="3">
<tr>
<td width="443"><img src="header_admin.jpg" width="500" height="150" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" enctype="multipart/form-data">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Categoria:</td>
<td><div align="left">
<select name="id_cat" class="todopanel">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['id']?>"><?php echo $row_Recordset1['nombre']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
</div></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Titulo:</td>
<td><div align="left">
<input type="text" name="titulo" value="" size="32" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Descripcion:</td>
<td><div align="left"><span class="textoINDEX">
<?php
$oFCKeditor = new FCKeditor('descripcion') ;
$oFCKeditor->BasePath = 'fckeditor/' ;
$oFCKeditor->Value = '<p></p>' ;
$oFCKeditor->Create() ;
?>
</span></div></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Metraje:</td>
<td><div align="left">
<input type="text" name="metraje" value="" size="32" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pecio:</td>
<td><div align="left">
<input type="text" name="pecio" value="" size="32" />
</div></td>
</tr>
<tr valign="baseline" bordercolor="#CCCCCC">
<td align="left" valign="top" class="tituloINDEX">Imagen principal:</td>
<td><div align="left">
<input name="imgprinc" type="file" class="textoINDEX" id="imgprinc" enctype="multipart/form-data" />
</div></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Enviar" /></td>
</tr>
</table>
<input type="hidden" name="id" value="" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Gracias de antemano