Foros del Web » Programando para Internet » PHP »

Query was empty

Estas en el tema de Query was empty en el foro de PHP en Foros del Web. Buenas, a ver si alguien me puede ayudar, ya que estoy pez con el PHP. He hecho un formulario para agregar distribuidores a mi base ...
  #1 (permalink)  
Antiguo 05/05/2015, 02:47
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 10 años
Puntos: 0
Query was empty

Buenas, a ver si alguien me puede ayudar, ya que estoy pez con el PHP. He hecho un formulario para agregar distribuidores a mi base de datos y a la hora de intentar rellenar el formulario me devuelve un "Query was empty".

Este es el código:

Código PHP:
<?php require_once('Connections/conexion.php'); ?>
<?php 
require_once('includes/funciones.php'); ?>
<?php 
if(isset( $_SESSION['MM_UserGroup']) &&  $_SESSION['MM_UserGroup']==1){?>
<?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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  
$updateSQL sprintf("UPDATE tbldistribuidores SET disNomEmp=%s, disActiEmp=%s, disNomCon=%s, disApelCon=%s, disTelefono=%s, disMovil=%s, disEmail=%s, disNotas=%s WHERE intId=%s",
                       
GetSQLValueString($_POST['disNomEmp'], "text"),
                       
GetSQLValueString($_POST['disActiEmp'], "text"),
                       
GetSQLValueString($_POST['disNomCon'], "text"),
                       
GetSQLValueString($_POST['disApelCon'], "text"),                  
                       
GetSQLValueString($_POST['disTelefono'], "int"),
                       
GetSQLValueString($_POST['disMovil'], "int"),
                       
GetSQLValueString($_POST['disEmail'], "text"),
                       
GetSQLValueString($_POST['disNotas'], "text"));

  
mysql_select_db($database_conexion$conexion);
  
$Result1 mysql_query($updateSQL$conexion) or die(mysql_error());

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


$UsuarioId_ModificarDatos "0";
if (isset(
$_GET['recordId'])) {
  
$UsuarioId_ModificarDatos $_GET['recordId'];
}
mysql_select_db($database_conexion$conexion);
$query_ModificarDatos sprintf("SELECT * FROM tbldistribuidores WHERE tbldistribuidores.intId= %s"GetSQLValueString($UsuarioId_ModificarDatos"int"));
$ModificarDatos mysql_query($query_ModificarDatos$conexion) or die(mysql_error());
$row_ModificarDatos mysql_fetch_assoc($ModificarDatos);
$totalRows_ModificarDatos mysql_num_rows($ModificarDatos);

?>
<!DOCTYPE html>
<html lang="es"><!-- InstanceBegin template="/Templates/Principal.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Prueba.es</title>
<meta name="description" content="">
<meta name="robots" content="index, follow">
<!-- InstanceEndEditable -->
<meta charset="utf-8">
<?php include("includes/precabecera.php"); ?>

<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>
<!-- InstanceBeginEditable name="EditRegion3" -->
<?php $menuseleccionado 6;?>
<section class="bg1">
  <!--==============================header=================================-->
  <header id="header">
    <div class="container_12">
      <?php include("includes/cabecera.php"); ?>
      <?php //include("includes/slider.php"); ?>
      <?php include("includes/menu.php"); ?>
    </div>
  </header>
  <!--===================content====================-->
  <div id="content">
    <div class="container_12">
        <div class="row">
 
            <div class="prefix_4 grid_6">
            <?php if (  isset($_GET['recordtext']) && $_GET['recordtext']=='1'){ ?>
            <br><br><div  class="mensajeenviado">Mensaje Guardado Correctamente</div>
            <?php }?>
              <h3 class="mrg22 pad3">Editar datos de: <?php echo $_GET['recordNameUser']; ?></h3>        
             
    <form method="POST" action="<?php echo $editFormAction?>" name="form2">    
                    <label class="name">
                      <h1>Nombre: </h1>
                      <input id="nombreempresa" name="disNomEmp"  class="seleccion" type="text" value="<?php echo htmlentities($row_ModificarDatos['disNomEmp'], ENT_COMPAT'utf-8'); ?>" onClick="javascript:  borrarnombreempresa();"/>
           
                      <div id="errorregistronombreempresa" class="ocultar texto-error">* Campo obligatorio</div>                        
                    </label>
                     <label class="name">
                          <br><br><h1>Actividad:</h1>
                          <input id="actividad" name="disActiEmp"  class="seleccion" type="text"  value="<?php echo htmlentities($row_ModificarDatos['disActiEmp'], ENT_COMPAT'utf-8'); ?>"  onClick="javascript:  borraraactividad();"/>
                           
                    <div id="errorregistroactividad" class="ocultar texto-error">* Campo obligatorio</div>
                    </label>
                    <label class="name">
                          <br><br><h1>Nombre:</h1>
                          <input id="nombre" name="disNomEmp"  class="seleccion" type="text"  value="<?php echo htmlentities($row_ModificarDatos['disNomEmp'], ENT_COMPAT'utf-8'); ?>"  onClick="javascript:  borrarnombre();"/>
                           
                    <div id="errorregistronombre" class="ocultar texto-error">* Campo obligatorio</div>
                    </label>
                    <label class="name">
                          <br><br><h1>Apellidos:</h1>
                          <input id="actividad" name="disApelEmp"  class="seleccion" type="text"  value="<?php echo htmlentities($row_ModificarDatos['disApelEmp'], ENT_COMPAT'utf-8'); ?>"  onClick="javascript:  borrarapellidos();"/>
                           
                    <div id="errorregistroapellidos" class="ocultar texto-error">* Campo obligatorio</div>
                    </label>
                    <label class="phone">
                        <br><br><h1>Teléfono:</h1><input id="telefonoregistro" name="disTelefono"  class="seleccion" type="text" value="<?php echo htmlentities($row_ModificarDatos['disTelefono'], ENT_COMPAT'utf-8'); ?>" onClick="javascript:  borrartelefono();"  />
                    <div id="errorregistrotelefono" class="ocultar texto-error">* Debe ser un Teléfono válido</div>
                    </label>
                    <label class="phone">
                        <br><br><h1>Móvil:</h1><input id="telefonoregistro" name="disMovil"  class="seleccion" type="text" value="<?php echo htmlentities($row_ModificarDatos['disMovil'], ENT_COMPAT'utf-8'); ?>" onClick="javascript:  borrartelefono();"  />
                    <div id="errorregistrotelefono" class="ocultar texto-error">* Debe ser un Teléfono válido</div>
                    </label>
                    <label class="email">
                      <br><br><h1>Email:</h1><input id="emailregistro" name="disEmail"  disabled class="seleccion" type="text" value="<?php echo htmlentities($row_ModificarDatos['disEmail'], ENT_COMPAT'utf-8'); ?>" />
                    <div id="errorregistroemail" class="ocultar texto-error">* Debe ser un Email válido</div>
                    <div id="errorregistroemailduplicado" class="ocultar texto-error">* Esta dirección de correo ya está siendo usada por un usuario</div>
                    </label>
                    <label class="phone">
                    <label class="message">
                      <br><br><h1>Notas:</h1><textarea id="mensajeregistro" class="seleccionarea" rows="5" name="disNotas" onClick="javascript:  borrarmensaje();" ><?php echo htmlentities($row_ModificarDatos['disNotas'], ENT_COMPAT'utf-8'); ?></textarea>
<div id="errorregistromensaje" class="ocultar texto-error">* Debe escribir un Mensaje</div>
                    </label>
                    <div>
                        <div class="clear"></div>
                        <div class="btns">
  #2 (permalink)  
Antiguo 05/05/2015, 02:48
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 10 años
Puntos: 0
Respuesta: Query was empty

Contiua...

Código PHP:
                           <!-- <a id="botonalta" class="btn" href="javascript: document.form2.submit()" onClick="javascript: return validar();">Enviar</a>  -->
                             <input id="botonalta" class="botton" type="submit" value="Aceptar" onClick="javascript: return validar();"><br>
               <br><br>

                   
                                           
                       
          </div>
                    </div>
  <input type="hidden" name="MM_update" value="form2">
  <input type="hidden" name="intId" value="<?php echo $row_ModificarDatos['intId']; ?>">
                </form>


                
<!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  
<!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->  <!---->           
     
          </div>
        </div>
    </div>
  </div>
  <!--===================footer=====================-->
  <?php include("includes/footer.php"); ?>
</section>
<!-- InstanceEndEditable -->
</body>
<!-- InstanceEnd -->

</html>
<?php
mysql_free_result
($ModificarDatos);
mysql_free_result($DatosCentros);
?>
<?php 
}else{ header("Location: index.php"); }/*restringir acceso a pagina*/?>
<script type="text/javascript">    
    function validar(){        
        validado = true;    
            
        valor = document.getElementById("nombreempresa").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistronombreempresa').show(1000);
              validado = false;
        }
        valor = document.getElementById("actividad").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistroactividad').show(1000);
              validado = false;
        } 
        valor = document.getElementById("nombre").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistronombre').show(1000);
              validado = false;
        } 
        valor = document.getElementById("apellidos").value;        
        if( valor == null || valor.length == 0 || /^\s+$/.test(valor) ) {
            $('#errorregistroapellidos').show(1000);
              validado = false;
        } 
            
    if (validado==false){return false;}            
    

    
    }
    </script>
    <script type="text/javascript">
function borrarnombreempresa(){
    $('#errorregistronombreempresa').hide(1000);
    }
function borraractividad(){
    $('#errorregistroactividad').hide(1000);
    }
function borrarnombre(){
    $('#errorregistronombre').hide(1000);
    }
function borraractividad(){
    $('#errorregistroapellidos').hide(1000);
    }
function borrarespecialidad(){
    $('#errorregistroespecialidad').hide(1000);
    }        
function borrarcentro(){
    $('#errorregistrocentro').hide(1000);
    }
function borrarlocalidadcentro(){
    $('#errorregistrolocalidadcentro').hide(1000);
    }
function borrartelefono(){
    $('#errorregistrotelefono').hide(1000);
    }    
function borrarmensaje(){    
    $('#errorregistromensaje').hide(1000);
    }
</script>
<script language="JavaScript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    return "Ha intentado salir de esta pagina. Si ha realizado algun cambio en los campos sin hacer clic en el boton Guardar, los cambios se perderan. Seguro que desea salir de esta pagina? ";
  }
</script>
  #3 (permalink)  
Antiguo 05/05/2015, 03:08
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 5 meses
Puntos: 2658
Respuesta: Query was empty

Demasiado código para un mensaje tan concreto. ..

Al momento de enviar la query, en alguna parte , estas enviando la variable vacía.
Verifica tu donde se pierde el contenido.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)

Etiquetas: empty, formulario, html, mysql, query, registro, select, sql
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 12:47.