Foros del Web » Programando para Internet » PHP »

Error en multi idioma

Estas en el tema de Error en multi idioma en el foro de PHP en Foros del Web. Hola amigos mi problema es que cuando entro en mi web me sale error en el select porque no hay ningun idioma selecionado he puesto ...
  #1 (permalink)  
Antiguo 19/09/2009, 12:20
Avatar de StrondA  
Fecha de Ingreso: mayo-2009
Mensajes: 21
Antigüedad: 15 años
Puntos: 0
Error en multi idioma

Hola amigos mi problema es que cuando entro en mi web me sale error en el select porque no hay ningun idioma selecionado he puesto para que si no hay ningun idioma selecionado aparezca la web en ingles por ejemplo pero me sale este error
Código PHP:
<b>Notice</b>:  Undefined index:  lang in <b>C:wampwwwUsuariosindex.php</bon line <b>26</b
si me pudiérais ayudar os estaria muy agradecido
  #2 (permalink)  
Antiguo 19/09/2009, 12:47
Avatar de DooBie  
Fecha de Ingreso: septiembre-2004
Mensajes: 1.101
Antigüedad: 19 años, 7 meses
Puntos: 71
Respuesta: Error en multi idioma

Si no pones el codigo, sera mas dificil ayudar, de todas formas, por el error, parece que intentas acceder a un indice de un array que no existe, por ejemplo
Código PHP:
$arr = array(2,3,5,1);
$var $arr[34]; 
revisa eso
  #3 (permalink)  
Antiguo 19/09/2009, 13:09
Avatar de StrondA  
Fecha de Ingreso: mayo-2009
Mensajes: 21
Antigüedad: 15 años
Puntos: 0
Respuesta: Error en multi idioma

éste es el codigo que yo estoy usando
Código PHP:
if(isset($_GET['lang']) == NULL){
include(
"lang/en.php");
}else{
$langs = array("en.php","es.php","pt-br.php");
include(
"lang/".$langs[$_GET['lang']]);

  #4 (permalink)  
Antiguo 19/09/2009, 13:27
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Respuesta: Error en multi idioma

Prueba haci:
Código php:
Ver original
  1. <?php
  2. if(isset($_GET['lang'])||empty($_GET['lang'])){
  3.     include("lang/en.php");
  4. }else{
  5.     $langs = array("en.php","es.php","pt-br.php");
  6.     include("lang/".(in_array($_GET['lang'],$langs)?$langs[$_GET['lang']]:$langs[0]));
  7. }  
  8. ?>
Suerte
Salu2
__________________
Half Music - www.halfmusic.com
  #5 (permalink)  
Antiguo 19/09/2009, 13:43
Avatar de urgido  
Fecha de Ingreso: febrero-2005
Mensajes: 2.351
Antigüedad: 19 años, 2 meses
Puntos: 25
Respuesta: Error en multi idioma

otra opción.

Código PHP:
Ver original
  1. if(isset($_GET['lang'])){
  2.  include("lang/en.php");
  3. }else{
  4. $langs = array("en.php","es.php","pt-br.php");
  5.  include("lang/".$langs[$_GET['lang']]);
  6. }
__________________
Hospedaje Web al mejor costo!
  #6 (permalink)  
Antiguo 19/09/2009, 14:11
Avatar de StrondA  
Fecha de Ingreso: mayo-2009
Mensajes: 21
Antigüedad: 15 años
Puntos: 0
Respuesta: Error en multi idioma

este script no me funciona tbn me da error
  #7 (permalink)  
Antiguo 19/09/2009, 14:24
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Respuesta: Error en multi idioma

y como es el dato que pasas por el get?
__________________
Half Music - www.halfmusic.com
  #8 (permalink)  
Antiguo 19/09/2009, 14:29
Avatar de urgido  
Fecha de Ingreso: febrero-2005
Mensajes: 2.351
Antigüedad: 19 años, 2 meses
Puntos: 25
Respuesta: Error en multi idioma

q error arroja? el mismo
__________________
Hospedaje Web al mejor costo!
  #9 (permalink)  
Antiguo 19/09/2009, 14:29
Avatar de urgido  
Fecha de Ingreso: febrero-2005
Mensajes: 2.351
Antigüedad: 19 años, 2 meses
Puntos: 25
Respuesta: Error en multi idioma

usa switch mejor :) seria una mejor forma
__________________
Hospedaje Web al mejor costo!
  #10 (permalink)  
Antiguo 19/09/2009, 14:50
Avatar de DooBie  
Fecha de Ingreso: septiembre-2004
Mensajes: 1.101
Antigüedad: 19 años, 7 meses
Puntos: 71
Respuesta: Error en multi idioma

Prueba esto a ver si te sirve...

Código PHP:
$lang 'en.php';
$dir_lang 'lang/';

$langs = array("en.php","es.php","pt-br.php");


if((
file_exists($dir_lang.$langs[$_GET['lang']])) && (is_file($dir_lang.$langs[$_GET['lang']]))){
  
$lang $langs[$_GET['lang']];
}

include_once(
$dir_lang.$lang); 
  #11 (permalink)  
Antiguo 19/09/2009, 15:08
Avatar de StrondA  
Fecha de Ingreso: mayo-2009
Mensajes: 21
Antigüedad: 15 años
Puntos: 0
Respuesta: Error en multi idioma

mira este es el codigo entero que tengo

Código PHP:
<link href="estilo.css" rel="stylesheet" type="text/css" />
<?php
session_start
();
$lang 'en.php'
$dir_lang 'lang/'

$langs = array("en.php","es.php","pt-br.php"); 


if((
file_exists($dir_lang.$langs[$_GET['lang']])) && (is_file($dir_lang.$langs[$_GET['lang']]))){ 
  
$lang $langs[$_GET['lang']]; 


include_once(
$dir_lang.$lang); 
echo 
"<title>$lang_title ";
if(isset(
$_SESSION['s_username']) == NULL){
echo 
"</title>";
}else{
echo 
$_SESSION['s_username']."</title>";
}
   if(isset(
$_COOKIE['cookusername']) && isset($_COOKIE['cookpassword'])){
      
$_SESSION['s_username'] = $_COOKIE['cookusername'];
      
$_SESSION['s_password'] = $_COOKIE['cookpassword'];
      
header('Location: refresh.php');
   }else{
?>
<table border="0" width="100%" height="100%" align="center">
<tr><td align="right" valign="top" height="2">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<select name="lang">
<option <?php if($_GET['lang'] == NULL){echo "selected";}?>></option>
<option value="0" <?php if($_GET['lang'] == '0'){echo "selected";}?>>English</option>
<option value="1" <?php if($_GET['lang'] == '1'){echo "selected";}?>>Español</option>
<option value="2" <?php if($_GET['lang'] == '2'){echo "selected";}?>>Português(Brasil)</option>
</select>
<input type="submit" value="Ir" class="nada" />
</form>
</td></tr>
<tr><td align="center">
<FORM action="login.php?lang=<?php echo $_GET['lang'];?>" method="post">
<TABLE class="login" border="0">
  <TR>
    <TD align=right>Login: <INPUT size="15" 
      name="username"> </TD></TR>
  <TR>
    <TD align=right>Password: <INPUT type=password size=15 
      name=password> </TD></TR>
  <TR>
    <TD><input type="checkbox" checked="checked" value="1" name="recordar" /> <?php echo $lang_recorder?></TD>
  </TR>
  <TR><input type="hidden" name="ps" value="1" />
    <TD align=middle><INPUT type=submit value=Login> </TD></TR>
</FORM><br />
<tr><td>
<a href="register.php">Registrarse</a></td></tr>
</TABLE>
</td></tr></table>
<?php
}
?>
  #12 (permalink)  
Antiguo 19/09/2009, 15:35
Avatar de DooBie  
Fecha de Ingreso: septiembre-2004
Mensajes: 1.101
Antigüedad: 19 años, 7 meses
Puntos: 71
Respuesta: Error en multi idioma

Cita:
Iniciado por StrondA Ver Mensaje
mira este es el codigo entero que tengo

Código PHP:
<link href="estilo.css" rel="stylesheet" type="text/css" />
<?php
session_start
();
$lang 'en.php'
$dir_lang 'lang/'

$langs = array("en.php","es.php","pt-br.php"); 


if((
file_exists($dir_lang.$langs[$_GET['lang']])) && (is_file($dir_lang.$langs[$_GET['lang']]))){ 
  
$lang $langs[$_GET['lang']]; 


include_once(
$dir_lang.$lang); 
echo 
"<title>$lang_title ";
if(isset(
$_SESSION['s_username']) == NULL){
echo 
"</title>";
}else{
echo 
$_SESSION['s_username']."</title>";
}
   if(isset(
$_COOKIE['cookusername']) && isset($_COOKIE['cookpassword'])){
      
$_SESSION['s_username'] = $_COOKIE['cookusername'];
      
$_SESSION['s_password'] = $_COOKIE['cookpassword'];
      
header('Location: refresh.php');
   }else{
?>
<table border="0" width="100%" height="100%" align="center">
<tr><td align="right" valign="top" height="2">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<select name="lang">
<option <?php if($_GET['lang'] == NULL){echo "selected";}?>></option>
<option value="0" <?php if($_GET['lang'] == '0'){echo "selected";}?>>English</option>
<option value="1" <?php if($_GET['lang'] == '1'){echo "selected";}?>>Español</option>
<option value="2" <?php if($_GET['lang'] == '2'){echo "selected";}?>>Português(Brasil)</option>
</select>
<input type="submit" value="Ir" class="nada" />
</form>
</td></tr>
<tr><td align="center">
<FORM action="login.php?lang=<?php echo $_GET['lang'];?>" method="post">
<TABLE class="login" border="0">
  <TR>
    <TD align=right>Login: <INPUT size="15" 
      name="username"> </TD></TR>
  <TR>
    <TD align=right>Password: <INPUT type=password size=15 
      name=password> </TD></TR>
  <TR>
    <TD><input type="checkbox" checked="checked" value="1" name="recordar" /> <?php echo $lang_recorder?></TD>
  </TR>
  <TR><input type="hidden" name="ps" value="1" />
    <TD align=middle><INPUT type=submit value=Login> </TD></TR>
</FORM><br />
<tr><td>
<a href="register.php">Registrarse</a></td></tr>
</TABLE>
</td></tr></table>
<?php
}
?>
y...?

quiero decir, funciona no funciona, dinos que pasa al poner la ultima modificacion
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 14:20.