Ver Mensaje Individual
  #9 (permalink)  
Antiguo 21/01/2011, 08:41
Avatar de Nano_
Nano_
 
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 3 meses
Puntos: 96
Respuesta: Ayuda con checkbox y php

Saludos

Revisar donde haces el insert into saque la seccion del if del sprintf, coloque un comentario para que te guies

Código PHP:
Ver original
  1. <?php
  2.  
  3. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
  4.     $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  5.  
  6.     switch ($theType) {
  7.         case "text":
  8.             $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  9.             break;
  10.         case "long":
  11.         case "int":
  12.             $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  13.             break;
  14.         case "double":
  15.             $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  16.             break;
  17.         case "date":
  18.             $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  19.             break;
  20.         case "defined":
  21.             $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  22.             break;
  23.     }
  24.     return $theValue;
  25. }
  26.  
  27. $editFormAction = $_SERVER['PHP_SELF'];
  28. if (isset($_SERVER['QUERY_STRING'])) {
  29.     $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  30. }
  31.  
  32. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  33. /***********************************************************   /
  34. //Inclui las siguientes lineas no puedes hacer un if dentro de un sprintf
  35. /************************************************************/
  36.     $monto=0;
  37.     $fecha="";
  38.     if ($_POST['chkIva']) {
  39.         $monto = GetSQLValueString($_POST['monto'] * 0.19, "int");
  40.         $fecha = GetSQLValueString($_POST['hora'] . ":" . $_POST['minuto'], "date");
  41.     }
  42.     $insertSQL = sprintf("INSERT INTO actividades (ot_id, actividad, monto, iva, horas_soporte) VALUES (%s, %s, %s, %s, %s)",
  43.                     GetSQLValueString($_POST['hiddenField'], "int"),
  44.                     GetSQLValueString($_POST['actividad'], "text"),
  45.                     GetSQLValueString($_POST['monto'], "int"),
  46.                     $monto,
  47.                     $fecha);
  48.  
  49.  
  50.     mysql_select_db($database_connBD, $connBD);
  51.     $Result1 = mysql_query($insertSQL, $connBD) or die(mysql_error());
  52.     $insertGoTo = "cerrarPopUp.php";
  53.     if (isset($_SERVER['QUERY_STRING'])) {
  54.         $insertGoTo .= ( strpos($insertGoTo, '?')) ? "&" : "?";
  55.         $insertGoTo .= $_SERVER['QUERY_STRING'];
  56.     }
  57.     header(sprintf("Location: %s", $insertGoTo));
  58. }
  59. ?>
__________________
:.:Nano.:: @nano_hard - Retornando al foro