Foros del Web » Programando para Internet » PHP »

Mensaje warning en php

Estas en el tema de Mensaje warning en php en el foro de PHP en Foros del Web. Hola, tengo un problema con unos mensajes que me salen en mis fomularios. no me interrumpen nada pero de todas maneras son mensajes que quisiera ...
  #1 (permalink)  
Antiguo 12/12/2012, 20:58
 
Fecha de Ingreso: agosto-2012
Ubicación: Lima, Peru
Mensajes: 51
Antigüedad: 11 años, 8 meses
Puntos: 0
Mensaje warning en php

Hola, tengo un problema con unos mensajes que me salen en mis fomularios. no me interrumpen nada pero de todas maneras son mensajes que quisiera eliminar.
Agrego que en la pagina donde aparece estos mensajes tiene interaccion con una base de datos, hay consulta, ingreso de registros, eliminacion de registros, y modificacion de registros.

Los mensajes se dan al momento de visualizarla desde el navegador y cuando ya estan en un servidor, desde el WAMP no me muestra ningun error pero cuando ya este en el servidor y lo veo desde un navegador me dan estos mensajes.

Warning: Cannot modify header information - headers already sent by (output started at /home/content/11/9802211/html/hdtech/formulario-notebooks.php:232) in /home/content/11/9802211/html/hdtech/formulario-notebooks.php on line 487

Warning: Cannot modify header information - headers already sent by (output started at /home/content/11/9802211/html/hdtech/formulario-notebooks.php:232) in /home/content/11/9802211/html/hdtech/formulario-notebooks.php on line 489

Tambien este

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/11/9802211/html/hdtech/modificarconfirmar.php on line 107

Última edición por XxSoulDarkxX; 12/12/2012 a las 21:04
  #2 (permalink)  
Antiguo 12/12/2012, 21:10
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Mensaje warning en php

Los primeros mensajes de error son bastante comunes, lee lo siguiente:
http://www.forosdelweb.com/wiki/PHP:...n_line_4%22%3F

El último error no es tan sencillo de solucionar pues no es un error de código sino de conexión, es mejor que uses PDO para poder controlar la excepción y que de una vez migres a MySQLi, lee lo siguiente:
http://www.forosdelweb.com/f18/anunc...ecada-1008145/
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 12/12/2012, 21:21
 
Fecha de Ingreso: agosto-2012
Ubicación: Lima, Peru
Mensajes: 51
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Mensaje warning en php

Cita:
Iniciado por pateketrueke Ver Mensaje
Los primeros mensajes de error son bastante comunes, lee lo siguiente:
http://www.forosdelweb.com/wiki/PHP:...n_line_4%22%3F

El último error no es tan sencillo de solucionar pues no es un error de código sino de conexión, es mejor que uses PDO para poder controlar la excepción y que de una vez migres a MySQLi, lee lo siguiente:
http://www.forosdelweb.com/f18/anunc...ecada-1008145/
Hola, la verdad no puedo encontrar el error. Soy nuevo en php y bases de datos, y es mi primera web algo compeja, te pego el codigo haber si me ayudas a encontrar el error.

Código PHP:
<?php require_once('Connections/conexion_usuarios.php'); ?>
<?php
//empieza el codigo para la validacion del usuario
//initialize the session
if (!isset($_SESSION)) {
  
session_start();
}
// ** Logout the current user. **
$logoutAction $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  
$logoutAction .="&"htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  
//to fully log out a visitor we need to clear the session varialbles
  
$_SESSION['MM_Username'] = NULL;
  
$_SESSION['MM_UserGroup'] = NULL;
  
$_SESSION['PrevUrl'] = NULL;
  unset(
$_SESSION['MM_Username']);
  unset(
$_SESSION['MM_UserGroup']);
  unset(
$_SESSION['PrevUrl']);
  
$logoutGoTo "index.php";
  if (
$logoutGoTo) {
    @
header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers "";
$MM_donotCheckaccess "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid False
 
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  
if (!empty($UserName)) { 
    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    
$arrUsers Explode(","$strUsers); 
    
$arrGroups Explode(","$strGroups); 
    if (
in_array($UserName$arrUsers)) { 
      
$isValid true
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup$arrGroups)) { 
      
$isValid true
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}
$MM_restrictGoTo "ingreso.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar "?";
  
$MM_referrer $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
  if (isset(
$QUERY_STRING) && strlen($QUERY_STRING) > 0
  
$MM_referrer .= "?" $QUERY_STRING;
  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
  @
header("Location: "$MM_restrictGoTo); 
  exit;
}
?>
<?php
$colname_consulta_usuario 
"-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_consulta_usuario = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_conexion_usuarios$conexion_usuarios);
$query_consulta_usuario sprintf("SELECT `user` FROM usuarios WHERE `user` = '%s'"$colname_consulta_usuario);
$consulta_usuario mysql_query($query_consulta_usuario$conexion_usuarios) or die(mysql_error());
$row_consulta_usuario mysql_fetch_assoc($consulta_usuario);
$totalRows_consulta_usuario mysql_num_rows($consulta_usuario);
//termina codigo para la conexion
//termina codigo para la conexion//termina codigo para la conexion
//termina codigo para la conexion
?>
<?php 
require_once('Connections/con_imag.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;
}
}
$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    
$tipo_prod $_POST["lstTipo"];
//Guardar imagen
    
if (is_uploaded_file($_FILES['fleImagen']['tmp_name']))  { // verifica haya sido cargado el archivo
        
$ruta"images/$tipo_prod/".$_FILES['fleImagen']['name'];
        
move_uploaded_file($_FILES['fleImagen']['tmp_name'], $ruta);
    if (
is_uploaded_file($_FILES['fleimagen_grande']['tmp_name']))  { // verifica haya sido cargado el archivo
        
$ruta1"images/$tipo_prod/".$_FILES['fleimagen_grande']['name'];
        
move_uploaded_file($_FILES['fleimagen_grande']['tmp_name'], $ruta1);
    if (
is_uploaded_file($_FILES['fleimagenmuestra1']['tmp_name']))  { // verifica haya sido cargado el archivo
        
$ruta2"images/$tipo_prod/".$_FILES['fleimagenmuestra1']['name'];
        
move_uploaded_file($_FILES['fleimagenmuestra1']['tmp_name'], $ruta2);
    if (
is_uploaded_file($_FILES['fleimagenmuestra2']['tmp_name']))  { // verifica haya sido cargado el archivo
        
$ruta3"images/$tipo_prod/".$_FILES['fleimagenmuestra2']['name'];
        
move_uploaded_file($_FILES['fleimagenmuestra2']['tmp_name'], $ruta3);
        }
        }
    }
    }  
// Referencia, Imagen, Tipo, Precio, Nombre, Descripcion
$insertSQL sprintf("INSERT INTO notebooks ( codigo, fabricante, Tipo, serie_modelo, nombre_modelo, precio, Imagen, imagen_grande, imagenmuestra1, imagenmuestra2, descripcion, descripcioncorta, sistema_operativo, procesador, chipset, memoria_instalada, memoria_maxima, disco_duro, unidad_optica, monitor, graficos, usb_30, usb_20, vga_monitor, hdmi_monitor, displayport, salida_audifonos, entrada_microfono, alimentacion_ca, rj_11, rj_45, interfaz_red, conexion_inalambrica, bluetooth ,bateria, audio, camara_web, teclado, dimensiones, peso, garantia, en_venta) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,  %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['txtcodigo'], "int"),
                       
GetSQLValueString($_POST['lstfabricante'], "text"),
                       
GetSQLValueString($_POST['lstTipo'], "text"),
                       
GetSQLValueString($_POST['txtserie_modelo'], "text"),
                       
GetSQLValueString($_POST['txtnombre_modelo'], "text"), "text"),
                       
GetSQLValueString($_POST['txtentrada_microfono'], "text"),
                       
GetSQLValueString($_POST['txtalimentacion_ca'], "text"),
                       
GetSQLValueString($_POST['txtrj_11'], "text"),
                       
GetSQLValueString($_POST['lsten_venta'], "text"));
  
mysql_select_db($database_con_imag$con_imag);
  
$Result1 mysql_query($insertSQL$con_imag) or die(mysql_error());
  
$insertGoTo "ingreso_exitoso.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  @
header(sprintf("Location: %s"$insertGoTo));
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Recorte el codigo porque es muy largo, espero sea suficiente.
  #4 (permalink)  
Antiguo 12/12/2012, 21:38
 
Fecha de Ingreso: agosto-2012
Ubicación: Lima, Peru
Mensajes: 51
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Mensaje warning en php

ya se cual fue es el problema.

Le elimine las lineas de los cokies y ya no muestra mensaje pero quiero saber que estan mal con ellos..


Código PHP:
</script>
    <tr>
        <td><strong>Descripcion corta(100 letras):</strong></td>
        <td><label for="txtdescripcioncorta"></label>
      <textarea name="txtdescripcioncorta" id="txtdescripcioncorta" cols="45" rows="5" onKeyUp="return maximaLongitud(this,95)"></textarea></td>
    </tr>
        <tr>
      <td><strong>En Venta:</strong></td>
      <td><label for="lsten_venta"></label>
        <select name="lsten_venta" id="lsten_venta">
          <option value="Si" selected="selected">Si</option>
          <option value="No">No</option>
      </select></td>
    </tr>
     <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="button" id="button" value="Enviar" /></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<?php
$rows
=mysql_query("select * from notebooks" );
$total=mysql_num_rows($rows);
$var="notebooks";
setcookie('cooki'$vartime()+3600);
$var2="formulario-notebooks.php";
setcookie('cookie'$var2time()+3600);
?>
<form name="form2" id="form2" method="post" onsubmit="return selectedVals();">
<table border="1" align="center" width="800px">
<tr>
   <th width="71">
   <input type="checkbox" name="selectail" id="selectail" onclick="CheckUncheck(<?php echo $total;?>,this);"/> codigo
   </th>
   <th width="203">
   modelo
   </th>
   <th width="337">
   En Venta?
   </th>
   <th width="337">
   Precio
   </th>
</tr>
<?php
$contador
=0;
while(
$row=mysql_fetch_array($rows)){
    
$contador=$contador+1;
?>
  #5 (permalink)  
Antiguo 12/12/2012, 21:42
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Mensaje warning en php

¿No has leído ninguno de los enlaces que te pase verdad?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #6 (permalink)  
Antiguo 12/12/2012, 21:49
 
Fecha de Ingreso: agosto-2012
Ubicación: Lima, Peru
Mensajes: 51
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Mensaje warning en php

Cita:
Iniciado por pateketrueke Ver Mensaje
¿No has leído ninguno de los enlaces que te pase verdad?
El primero lo ley pero no entiendo como ubicar el posible error en el codigo.

Al final descubri que el error se muestra al poner los cokies, los movi al final del codigo y probema resuelto.

Pero sigo teniendo problemas con el otro mensaje en la pagina de modificacion de registro, si modifica los registros pero de todas maneras me sale ese mensaje de:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/11/9802211/html/hdtech/modificarconfirmar.php on line 107
  #7 (permalink)  
Antiguo 12/12/2012, 21:56
 
Fecha de Ingreso: agosto-2012
Ubicación: Lima, Peru
Mensajes: 51
Antigüedad: 11 años, 8 meses
Puntos: 0
Respuesta: Mensaje warning en php

Listo, ya lo solucione, el error de Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/11/9802211/html/hdtech/modificarconfirmar.php on line 107

Se debia que se repetia la conexion a la bd, elimine la segunda conexcion y quedo todo perfecto.

Etiquetas: formulario, html, mensaje, mysql, sql, warning
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 20:51.