El sistema deberia insertar multiples registros, comprobando antes si la fecha (con el usuario ingresado) ya existe o no. Como mi conocimiento de PHP es muy basico y no logre realizarlo solo, tuve que recurrir a Dreamweaver; y el tema es que la funcion de comprobacion funciona bien sola, y la de la inserción multiple tambien funciona bien sola, pero al ponerlas juntas me da un error:
Notice: Array to string conversion in C:\xampp\htdocs\Epidemiologia3\cargafebriles.php on line 113
Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\xampp\htdocs\Epidemiologia3\cargafebriles.php on line 83
Unknown column 'Array' in 'where clause'
Y no logro dar con mi equivocación. Porfavor si pueden indicarme que estoy haciendo mal
 ... Se los agradecere muchisimo.
 ... Se los agradecere muchisimo.Aqui va el codigo PHP:
Código PHP:
   <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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 . "'" : "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;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
  $MM_dupKeyRedirect="error.php";
  $loginUsername = $_POST['fecha'];
  $usuariod = $_POST['us'];
  $LoginRS__query = sprintf("SELECT fecha, us FROM mi_tabla WHERE fecha=%s AND us=$usuariod", GetSQLValueString($loginUsername, "date"));
  mysql_select_db($database_baseprueba, $baseprueba);
  $LoginRS=mysql_query($LoginRS__query, $baseprueba) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  //if there is a row in the database, the username was found - can not add the requested username
  if($loginFoundUser){
    $MM_qsChar = "?";
    //append the username to the redirect page
    if (substr_count($MM_dupKeyRedirect,"?") >=10) $MM_qsChar = "&";
    $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
    header ("Location: $MM_dupKeyRedirect");
    exit;
  }
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
     foreach($_POST["id"] as $key => $value) {
  $insertSQL = sprintf("INSERT INTO febriles (id, cantidad,edad, fecha, us, loc, zona) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['id'][$key], "int"),
                       GetSQLValueString($_POST['cantidad'][$key], "int"),
                       GetSQLValueString($_POST['edad'][$key], "int"),
                       GetSQLValueString($_POST['fecha'][$key], "date"),
                       GetSQLValueString($_POST['us'][$key], "int"),
                       GetSQLValueString($_POST['loc'][$key], "int"),
                       GetSQLValueString($_POST['zona'][$key], "int"));
  mysql_select_db($database_baseprueba, $baseprueba);
  $Result1 = mysql_query($insertSQL, $baseprueba) or die(mysql_error());
  $insertGoTo = "panel.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }}
  header(sprintf("Location: %s", $insertGoTo));
}    Código HTML:
 <form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2"> <table align="center"> <tr valign="baseline"> <td width="154" align="right" nowrap="nowrap">Edades:</td> <td width="173">Cantidad:</td> </tr> <?php do { ?> <tr valign="baseline"> <td nowrap="nowrap" align="right"><?php echo $row_rs_edad['rango_edad']; ?><input name="id_edad[]" type="hidden" id="id_edad[]" value="<?php echo $row_rs_edad['id_edad']; ?>" size="32" /></td> <td><input name="cantidad_feb[]" type="text" id="cantidad_feb[]" value="0" size="5" /> <input name="id[]" type="hidden" id="id[]" value="" /> <input name="us[]" type="hidden" id="id_us[]" value="<?php echo $row_rs_user['us']; ?>" size="32" /> <input name="loc[]" type="hidden" id="loc[]" value="<?php echo $row_rs_user['loc']; ?>" size="32" /> <input name="zona[]" type="hidden" id="zona[]" value="<?php echo $row_rs_user['zona']; ?>" size="32" /> <input name="fecha[]" type="hidden" id="fecha[]" value="<?php echo $row_rs_user['fecha']; ?>" /></td> </tr> <?php } while ($row_rs_edad = mysql_fetch_assoc($rs_edad)); ?> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Subir datos" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form2" /> </form>
 
 
 Consulta: Error al colocar foreach y comprobacion de registro juntos
 Consulta: Error al colocar foreach y comprobacion de registro juntos 
 , te comparto el codigo php completo con la porcion de codigo que me pasaste:
, te comparto el codigo php completo con la porcion de codigo que me pasaste:

 Este tema le ha gustado a 1 personas
Este tema le ha gustado a 1 personas