Foros del Web » Programando para Internet » PHP »

[AYUDA] - funtion spintf

Estas en el tema de [AYUDA] - funtion spintf en el foro de PHP en Foros del Web. saludos tngo este problemita Warning: sprintf() [function.sprintf]: Too few arguments in C:\wamp\www\multisillas\site\admin\ing_prod.php on line 48 Query was empty y este es mi codigo Código PHP: ...
  #1 (permalink)  
Antiguo 07/04/2008, 14:57
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
[AYUDA] - funtion spintf

saludos tngo este problemita

Warning: sprintf() [function.sprintf]: Too few arguments in C:\wamp\www\multisillas\site\admin\ing_prod.php on line 48
Query was empty


y este es mi codigo

Código PHP:
<?php require_once('../Connections/multisillas.php'); ?>
<?php
include_once("fckeditor/fckeditor.php") ;
?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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'../imgprod/';  
$uploaddir=$ediciondir;
if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }
move_uploaded_file($_FILES['imagen']['tmp_name'], $uploaddir $_FILES['imagen']['name']);    
$filename $_FILES['imagen']['name'];


$insertSQL sprintf("INSERT INTO productos (id, id_cat, nombre, codigo, descripcion, imagen) VALUES (%s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id_cat'], "int"),
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['codigo'], "text"),
                       
GetSQLValueString($_POST['descripcion'], "text"),
                       
GetSQLValueString($filename"text"));

  
mysql_select_db($database_multisillas$multisillas);
  
$Result1 mysql_query($insertSQL$multisillas) or die(mysql_error());

  
$insertGoTo "listado_prod.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

mysql_select_db($database_multisillas$multisillas);
$query_Recordset1 "SELECT * FROM categoria";
$Recordset1 mysql_query($query_Recordset1$multisillas) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 07/04/2008, 15:06
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: [AYUDA] - funtion spintf

Hola T4keOver

El problema se presenta ya que en tu string que tienes en el sprintf tienes 6 place holders (%s), sin embargo en la lista de parámetros le pasas 5 variables, y te lanza el error.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:34.