Hola, necesito ayuda con este problema, al inciar sesión me sale el error "Cannot modify header information " en la linea 75 y 76 que corresponden a el código setcookie, busque la respuesta en este foro y suele ser los espacios, pero e mirado donde me sale error y demás archivos pero los saltos de linea son comúnes, no tengo erroneos, (no que yo considere). les agradecería me ayudaran.
<?php
//FORMATEO BASE DE DATOS
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;
}
}
//FORMATO DE CARACTERES
header('Content-Type: text/html; charset=iso-8859-1');
//CONSULTA BASE DATOS
mysql_select_db($database_conexion, $conexion);
$query_DatosWeb = "SELECT * FROM d_datos";
$DatosWeb = mysql_query($query_DatosWeb, $conexion) or die(mysql_error());
$row_DatosWeb = mysql_fetch_assoc($DatosWeb);
$totalRows_DatosWeb = mysql_num_rows($DatosWeb);
$dato= array($row_DatosWeb['url'],$row_DatosWeb['url2'],$row_DatosWeb['titulo'],$row_DatosWeb['admin']);
mysql_free_result($DatosWeb);
function nombre($iduser){
global $database_conexion, $conexion;
mysql_select_db($database_conexion, $conexion);
$query_DatosFuncion = sprintf("SELECT user FROM d_users WHERE id=%s",
GetSQLValueString($iduser, "int"));
$DatosFuncion = mysql_query($query_DatosFuncion, $conexion) or die(mysql_error());
$row_DatosFuncion = mysql_fetch_assoc($DatosFuncion);
$totalRows_DatosFuncion = mysql_num_rows($DatosFuncion);
return $row_DatosFuncion['user'];
mysql_free_result($DatosFuncion);
}
function recordarsesion($user,$pass){
setcookie("usercookie", $user, time() + (365 * 24 * 60 * 60),"/");
setcookie("passcookie", $pass, time() + (365 * 24 * 60 * 60),"/");
}
if (isset($_COOKIE['usercookie']) && isset($_COOKIE['passcookie']) && !isset($_SESSION['iduser'])) {
mysql_select_db($database_conexion, $conexion);
$query_DatosLogin = sprintf("SELECT * FROM d_users WHERE user=%s AND password=%s",
GetSQLValueString($_COOKIE['usercookie'], "text"),
GetSQLValueString($_COOKIE['passcookie'], "text"));
$DatosLogin = mysql_query($query_DatosLogin, $conexion) or die(mysql_error());
$row_DatosLogin = mysql_fetch_assoc($DatosLogin);
$totalRows_DatosLogin = mysql_num_rows($DatosLogin);
if ($totalRows_DatosLogin==1){
$_SESSION['iduser']=$row_DatosLogin['id'];
$_SESSION['nombreuser']=$row_DatosLogin['user'];
}
mysql_free_result($DatosLogin);
}
?>0
Puntos
Puntos
1248
Visitas
Visitas
6
Resp
Resp
Por andresc9410 hace 9 años
Novice
Respuesta #1
hola, el error no esta en este fichero (al parecer), aunque suene repetitivo el error que te marca es por un salto de linea
comprueba el fichero conexion.php y login.php es muy posible ahí este el fallo, ya de paso comprueba todos los fichero php y se ves algo como esto:
salu2
comprueba el fichero conexion.php y login.php es muy posible ahí este el fallo, ya de paso comprueba todos los fichero php y se ves algo como esto:
<?php
?>
<----------------salto de linea
<?php
?>elimínalo..salu2
0
Puntos
Puntos
Por alber hace 9 años
Admin
Respuesta #2
Nada.. no veo nada raro..
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
//SESSIONES
if (!isset($_SESSION)) {
session_start();
}
$hostname_conexion = "localhost";
$database_conexion = "Dacfmovies";
$username_conexion = "root";
$password_conexion = "root";
$conexion = mysql_pconnect($hostname_conexion, $username_conexion, $password_conexion) or trigger_error(mysql_error(),E_USER_ERROR);
include('inc/funciones.php')
?><?php require_once('../conexion.php');
mysql_select_db($database_conexion, $conexion);
$query_DatosLogin = sprintf("SELECT * FROM d_users WHERE user=%s AND password=%s",
GetSQLValueString($_POST['user'], "text"),
GetSQLValueString(md5($_POST['pass']), "text"));
$DatosLogin = mysql_query($query_DatosLogin, $conexion) or die(mysql_error());
$row_DatosLogin = mysql_fetch_assoc($DatosLogin);
$totalRows_DatosLogin = mysql_num_rows($DatosLogin);
if ($totalRows_DatosLogin==1){
$_SESSION['iduser']=$row_DatosLogin['id'];
$_SESSION['nombreuser']=$row_DatosLogin['user'];
echo 'yes';
if ($_POST['recordar']=='on'){
recordarsesion($row_DatosLogin['user'],$row_DatosLogin['password']);
}
} else {
echo 'error';
}
mysql_free_result($DatosLogin);
?>0
Puntos
Puntos
Por andresc9410 hace 9 años
Novice
Respuesta #3
no sera por esto??
error_reporting(E_ALL ^ E_DEPRECATED);ten en cuenta que estas usando mysql podrias pasarlo a mysqli fácil https://phpres.net/php-poo/ejemplos-de-como-usar-mysqli-de-manera-facil
0
Puntos
Puntos
Por alber hace 9 años
Admin
Respuesta #4
No creo.. agg no! me tocaría modificar prácticamente todo el código, no hay otra forma, será ese el error?
0
Puntos
Puntos
Por andresc9410 hace 9 años
Novice
Respuesta #5
no tienes que cambiar todo en código solo agregar una i donde veas mysql y cambiar la conexión, el error es un salto de linea y tiene que estar en alguna parte pero para poder localizarlo tendria que ver el proyecto completo
otra solución algo chapucera es con
otra solución algo chapucera es con
error_reporting(0);salu2 y suerte
0
Puntos
Puntos
Por alber hace 9 años
Admin
Respuesta #6
Vale gracias por la ayuda, un saludo.
0
Puntos
Puntos
Por andresc9410 hace 9 años
Novice