Foros del Web » Programando para Internet » PHP »

Pregunta sobre sobre error en codigo

Estas en el tema de Pregunta sobre sobre error en codigo en el foro de PHP en Foros del Web. Hola a todos, soy nuevo. Aprobecha este primer post para consultar sobre un error que estoy tenindo. En mi servidor local el codigo carga perfecto. ...
  #1 (permalink)  
Antiguo 03/06/2008, 22:42
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Pregunta sobre sobre error en codigo

Hola a todos, soy nuevo.

Aprobecha este primer post para consultar sobre un error que estoy tenindo. En mi servidor local el codigo carga perfecto. Pero el problema surge al subirlo a mi hosting. La pagina se refresca (actualiza) contantemente.

El codigo que creo que es donde esta el error (ya que quitando este codigo se arreglar el problema):

<?
/************************************************** ************************************
Originally from http://www.phpbuddy.com/article.php?id=8
Author: Ranjit Kumar (Cheif Editor phpbuddy.com)
Modified by: Ying Zhang (Dodo) http://pure-essence.net
Two main modifications:
1. To check currently saved screen resolution cookie
2. To allow inclusion by other php files

In order to use this file in another php file, use:

$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";

************************************************** ***************************************/
?>

<script language="javascript">
<!--
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
if (document.cookie){
location = '<?=$GLOBALS[callget_res_page_name]?>';
}

}


function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>

<?
if(isset($HTTP_COOKIE_VARS["users_res"])) {
$screen_res = $HTTP_COOKIE_VARS["users_res"];
$screen_res_tmp = explode("x", $screen_res);
$screen_width = $screen_res_tmp[0];
$screen_height = $screen_res_tmp[1];
?>
<script language="javascript">
<!--
checkRes(<?=$screen_width?>, <?=$screen_height?>);
//-->
</script>
<?
}
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>
<?
}
?>

Lo que hace en si el codigo es verificar la resolucion del usuario.
  #2 (permalink)  
Antiguo 03/06/2008, 22:57
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Pregunta sobre sobre error en codigo

buen codigo... pero parece que debes agregar el error que te sale... o simplemente se bloquea el servidor???

bueno... la primera es pon comillas dentro de las llaves, de los arreglos.... ej. $GLOBALS[sin_comillas] por $GLOBALS['sin_comillas'] ( :P bueno, con... comillas )

la otra... activa el sistema de reporte de errores con... error_reporting(E_ALL);

has esto antes de ejecutar el script... vaya, en el mismo script agrega estas sentencias y nos avisas...
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 04/06/2008, 00:15
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Cita:
Iniciado por pateketrueke Ver Mensaje
buen codigo... pero parece que debes agregar el error que te sale... o simplemente se bloquea el servidor???

bueno... la primera es pon comillas dentro de las llaves, de los arreglos.... ej. $GLOBALS[sin_comillas] por $GLOBALS['sin_comillas'] ( :P bueno, con... comillas )

la otra... activa el sistema de reporte de errores con... error_reporting(E_ALL);

has esto antes de ejecutar el script... vaya, en el mismo script agrega estas sentencias y nos avisas...
El tema esta en que el codigo hace que se produzca un bucle infinito que hace que se actulize la pagina contantemente. Osea que ni llega a cargar la pagina.
  #4 (permalink)  
Antiguo 04/06/2008, 00:37
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Pregunta sobre sobre error en codigo

claro... pero no solamente estas usando PHP, entonces... hay que estar seguros de que el error es de PHP, para solucionarlo... tienes que arreglar estos desperfectos que mencione, ya que pueden ser una causa....

otra cosa... al parecer no hay PHP, que haga ciclos... en tu codigo, ni siquiera un header() entonces... seguro que el problema puede ser de Javascript, quiere decir... que (como se ve) usas PHP para rellenar algunos datos para JS.... a eso me refiero

digo... esa es una posible causa, animo!
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 04/06/2008, 03:05
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Cita:
Iniciado por pateketrueke Ver Mensaje
claro... pero no solamente estas usando PHP, entonces... hay que estar seguros de que el error es de PHP, para solucionarlo... tienes que arreglar estos desperfectos que mencione, ya que pueden ser una causa....

otra cosa... al parecer no hay PHP, que haga ciclos... en tu codigo, ni siquiera un header() entonces... seguro que el problema puede ser de Javascript, quiere decir... que (como se ve) usas PHP para rellenar algunos datos para JS.... a eso me refiero

digo... esa es una posible causa, animo!
Exacto. El codigo PHP lo tengo para rellenar una variable de un javascript. Pero lo raro es que en local me funciona.
  #6 (permalink)  
Antiguo 04/06/2008, 03:12
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Codigo index.php

<body>

<?php
$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
$screen_width;
$res1= $screen_width;
if ($res1 == '1280') {
$res2 = '231';
$res3 = '340';
}
$res1= $screen_width;
if ($res1 == '1024') {
$res2 = '103';
$res3 = '212';
}
$res1= $screen_width;
if ($res1 == '800') {
$res2 = '0';
$res3 = '100';
}


?>


<div id="header">
<div id="logo">
<h1><a href=""></a></h1>
<h2><a href=""></a></h2>
</div>
</div>


<div>
<script language="JavaScript1.2" src="coolmenus3.js">
/************************************************** ***************************
Copyright (c) 2001 Thomas Brattli (www.bratta.com)

eXperience DHTML coolMenus - Get it at www.bratta.com
Version 3.02
This script can be used freely as long as all copyright messages are
intact.
************************************************** ****************************/
</script>
<script>
/************************************************** ***************************
Default browsercheck - Leave this one
************************************************** ****************************/
function lib_bwcheck(){ //Browsercheck (needed)
this.ver=navigator.appVersion; this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ie=this.ie4||this.ie5||this.ie6
this.mac=this.agent.indexOf("Mac")>-1
this.opera5=this.agent.indexOf("Opera 5")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom)
return this
}
var bw=new lib_bwcheck() //Making browsercheck object

var mDebugging=2 //General debugging variable. Set to 0 for no debugging, 1 for alerts or 2 for status debugging.

oCMenu=new makeCoolMenu("oCMenu") //Making the menu object. Argument: menuname
oCMenu.useframes=0 //Do you want to use the menus as coolframemenu or not? (in frames or not) - Value: 0 || 1
oCMenu.frame="frmMain" //The name of your main frame (where the menus should appear). Leave empty if you're not using frames - Value: "main_frame_name"

oCMenu.useclick=0 //If you want the menu to be activated and deactivated onclick only set this to 1. - Value: 0 || 1

/*If you set this to 1 you will get a "hand" cursor when moving over the links in NS4.
NOTE: This does not apply to the submenus if the menu is used in frames due some mayor problems with NS4*/
oCMenu.useNS4links=1

//After adding the "hover effect" for netscape as well, all styles are lost. But if you want padding add it here.
oCMenu.NS4padding=2

//If you have select boxes close to your menu the menu will check for that and hide them if they are in the way of the menu.
//This feature does unfortunatly not work in NS4!
oCMenu.checkselect=0

/*If you choose to have this code inside a linked js, or if your using frames it's important to set these variables.
This will help you get your links to link to the right place even if your files are in different folders.
The offlineUrl variable is the actual path to the directory where you js file are locally.
This is just so you can test it without uploading. Remember to start it with file:/// and only use slashes, no backward slashes!
Also remember to end with a slash */
oCMenu.offlineUrl="file:///C|/Inetpub/wwwroot/dhtmlcentral/" //Value: "path_to_menu_file_offline/"
//The onlineUrl variable is the online path to your script. Place in the full path to where your js file is. Remember to end with a slash.
oCMenu.onlineUrl="http://www.dhtmlcentral.com/coolmenus/examples/withoutframes/" //Value: "path_to_menu_file_online/"

oCMenu.pagecheck=0 //Do you want the menu to check whether any of the subitems are out of the bouderies of the page and move them in again (this is not perfect but it hould work) - Value: 0 || 1
oCMenu.checkscroll=0 //Do you want the menu to check whether the page have scrolled or not? For frames you should always set this to 1. You can set this to 2 if you want this feature only on explorer since netscape doesn't support the window.onscroll this will make netscape slower (only if not using frames) - Value: 0 || 1 || 2
oCMenu.resizecheck=0 //Do you want the page to reload if it's resized (This should be on or the menu will crash in Netscape4) - Value: 0 || 1
oCMenu.wait=1000 //How long to wait before hiding the menu on mouseout. Netscape 6 is a lot slower then Explorer, so to be sure that it works good enough there you should not have this lower then 500 - Value: milliseconds

//Background bar properties
oCMenu.usebar=1 //If you want to use a background-bar for the top items set this on - Value: 1 || 0
oCMenu.barcolor="#5e6774" //The color of the background bar - Value: "color"
oCMenu.barwidth="800" //The width of the background bar. Set this to "menu" if you want it to be the same width as the menu. (this will change to match the border if you have one) - Value: px || "%" || "menu"
oCMenu.barheight="menu" //The height of the background bar. Set this to "menu" if you want it to be the same height as the menu. (this will change to match the border if you have one) - Value: px || "%" || "menu"
oCMenu.barx= <? echo $res2; ?> //The left position of the bar. Set this to "menu" if you want it be the same as the left position of the menu. (this will change to match the border if you have one) - Value: px || "%" || "menu"
oCMenu.bary=150.4 //The top position of the bar Set this to "menu" if you want it be the same as the top position of the menu. (this will change to match the border if you have one) - Value: px || "%" || "menu"
oCMenu.barinheritborder=0 //Set this to 1 if you want the bar to have the same border as the top menus - Value: 0 || 1

//Placement properties
oCMenu.rows=1 //This controls whether the top items is supposed to be laid out in rows or columns. Set to 0 for columns and 1 for row - Value 0 || 1
oCMenu.fromleft= <? echo $res3; ?> //This is the left position of the menu. (Only in use if menuplacement below is 0 or aligned) (will change to adapt any borders) - Value: px || "%"
oCMenu.fromtop=150 //This is the left position of the menu. (Only in use if menuplacement below is 0 or aligned) (will change to adapt any borders) - Value: px || "%"
oCMenu.pxbetween=0 //How much space you want between each of the top items. - Value: px || "%"
  #7 (permalink)  
Antiguo 04/06/2008, 03:13
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Como ves, se trata de determina la resolucion del usuario, y apartir de ahi acomodar el menu flotante en javascript segun las coordenadas de los pixeles.
  #8 (permalink)  
Antiguo 04/06/2008, 03:19
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Ya intente cambiar lo de las comillas, y nada :S
  #9 (permalink)  
Antiguo 04/06/2008, 13:14
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

¿Alguien me ayuda?
  #10 (permalink)  
Antiguo 04/06/2008, 13:52
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Pregunta sobre sobre error en codigo

a mi me interesaría ver el código de ... get_resolution.php

sino... creo que el problema sigue en el direccionamiento de Javascript, ve al foro adecuado....
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #11 (permalink)  
Antiguo 04/06/2008, 14:06
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Cita:
Iniciado por pateketrueke Ver Mensaje
a mi me interesaría ver el código de ... get_resolution.php

sino... creo que el problema sigue en el direccionamiento de Javascript, ve al foro adecuado....
El codigo del get_resolution.php fue el primero que puse:

<?
/************************************************** ************************************
Originally from http://www.phpbuddy.com/article.php?id=8
Author: Ranjit Kumar (Cheif Editor phpbuddy.com)
Modified by: Ying Zhang (Dodo) http://pure-essence.net
Two main modifications:
1. To check currently saved screen resolution cookie
2. To allow inclusion by other php files

In order to use this file in another php file, use:

$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";

************************************************** ***************************************/
?>

<script language="javascript">
<!--
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
if (document.cookie){
location = '<?=$GLOBALS[callget_res_page_name]?>';
}

}


function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>

<?
if(isset($HTTP_COOKIE_VARS["users_res"])) {
$screen_res = $HTTP_COOKIE_VARS["users_res"];
$screen_res_tmp = explode("x", $screen_res);
$screen_width = $screen_res_tmp[0];
$screen_height = $screen_res_tmp[1];
?>
<script language="javascript">
<!--
checkRes(<?=$screen_width?>, <?=$screen_height?>);
//-->
</script>
<?
}
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>
<?
}
?>
  #12 (permalink)  
Antiguo 04/06/2008, 14:12
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Pregunta sobre sobre error en codigo

changos.... y ya viste en el foro de JS ?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #13 (permalink)  
Antiguo 04/06/2008, 14:19
Avatar de terepaima  
Fecha de Ingreso: junio-2008
Mensajes: 82
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: Pregunta sobre sobre error en codigo

Hola

Donde puedo ver tu codigo funcionando?

Me puedes dar la URL?
  #14 (permalink)  
Antiguo 04/06/2008, 14:22
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Pregunta sobre sobre error en codigo

bien, tuve que hacerlo....

Código PHP:
<?php

// YA ENTENDI!!!!
// ;)

/************************************************** ************************************
Originally from http://www.phpbuddy.com/article.php?id=8
Author: Ranjit Kumar (Cheif Editor phpbuddy.com)
Modified by: Ying Zhang (Dodo) http://pure-essence.net
Two main modifications:
1. To check currently saved screen resolution cookie
2. To allow inclusion by other php files

In order to use this file in another php file, use:

$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";

// JUSTO ARRIBA dice esto....

para usar este archivo en otro archivo, usa:

- declara la variable $call_Get_res_page_name con REQUEST_URI yo como, tengo
register_globals OFF entonces... es por medio de $_SERVER

- incluye el archivo get_resolution.php

y ya obtienes la resolucion por medio de $screen_width y $screen_height

---------------------------------- y luego....

- tambien habia comentado que las comillas son necesarias como llaves de cualquier arreglo

- luego, gracias a que tengo short_open_tag OFF tuve que reemplazar <? por <?php y los <?= por <?php echo
asi como sus faltantes punto-y-comas y otros caracteres de expresión...

- cambie $HTTP_COOKIE_VARS por $_COOKIE

.......... ya lo probe en mi servidor local y si, funciona... gracias!

************************************************** ***************************************/

$callget_res_page_name $_SERVER['REQUEST_URI']; // $_SERVER
$GLOBALS['callget_res_page_name'] = $callget_res_page_name// comillas !!!
?>



<script language="javascript">
<!--
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
if (document.cookie){
location = '<?php echo $GLOBALS['callget_res_page_name']; ?>';
}

}


function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>

<?php
if(isset($_COOKIE["users_res"])) {
$screen_res $_COOKIE["users_res"];
$screen_res_tmp explode("x"$screen_res);
$screen_width $screen_res_tmp[0];
$screen_height $screen_res_tmp[1];
?>
<script language="javascript">
<!--
checkRes(<?php echo $screen_width?><?php echo $screen_height?>);
//-->
</script>
<?php
}
else 
//means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>
<?php
}


// tal y como dice en los comentarios...
//
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";
?>
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Última edición por pateketrueke; 04/06/2008 a las 14:36
  #15 (permalink)  
Antiguo 04/06/2008, 15:43
 
Fecha de Ingreso: junio-2008
Mensajes: 9
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Pregunta sobre sobre error en codigo

Cita:
Iniciado por pateketrueke Ver Mensaje
bien, tuve que hacerlo....

Código PHP:
<?php

// YA ENTENDI!!!!
// ;)

/************************************************** ************************************
Originally from http://www.phpbuddy.com/article.php?id=8
Author: Ranjit Kumar (Cheif Editor phpbuddy.com)
Modified by: Ying Zhang (Dodo) http://pure-essence.net
Two main modifications:
1. To check currently saved screen resolution cookie
2. To allow inclusion by other php files

In order to use this file in another php file, use:

$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
include("get_resolution.php");
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";

// JUSTO ARRIBA dice esto....

para usar este archivo en otro archivo, usa:

- declara la variable $call_Get_res_page_name con REQUEST_URI yo como, tengo
register_globals OFF entonces... es por medio de $_SERVER

- incluye el archivo get_resolution.php

y ya obtienes la resolucion por medio de $screen_width y $screen_height

---------------------------------- y luego....

- tambien habia comentado que las comillas son necesarias como llaves de cualquier arreglo

- luego, gracias a que tengo short_open_tag OFF tuve que reemplazar <? por <?php y los <?= por <?php echo
asi como sus faltantes punto-y-comas y otros caracteres de expresión...

- cambie $HTTP_COOKIE_VARS por $_COOKIE

.......... ya lo probe en mi servidor local y si, funciona... gracias!

************************************************** ***************************************/

$callget_res_page_name $_SERVER['REQUEST_URI']; // $_SERVER
$GLOBALS['callget_res_page_name'] = $callget_res_page_name// comillas !!!
?>



<script language="javascript">
<!--
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
if (document.cookie){
location = '<?php echo $GLOBALS['callget_res_page_name']; ?>';
}

}


function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>

<?php
if(isset($_COOKIE["users_res"])) {
$screen_res $_COOKIE["users_res"];
$screen_res_tmp explode("x"$screen_res);
$screen_width $screen_res_tmp[0];
$screen_height $screen_res_tmp[1];
?>
<script language="javascript">
<!--
checkRes(<?php echo $screen_width?><?php echo $screen_height?>);
//-->
</script>
<?php
}
else 
//means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>
<?php
}


// tal y como dice en los comentarios...
//
echo $screen_width." is your screen width and ".$screen_height." is your screen height.";
?>
Muchisimas gracias!! Ahora si funciona!!!
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 22:29.