PHP和MYSQL:Echo无法正常工作

I used to store all my data in 000webhost, today I decided to move to hostinger. So.. after moving it I replaced the old mysql_connect info by the new one. Alright, after doing that I tested it, everything has ran fine, except some echo functions.

check file (connects to the server and do the login):

    <?php

    $servidorr = "mysql.XXXX.co.uk";
    $bdd = "XXXXXXXX";
    $usuarioo = "XXXXX";
    $senhaa = "XXXXXXX";


    if (!empty($_POST) AND (empty($_POST['usuario']) OR empty($_POST['senha']))) {
        header("Location: geton"); exit;
    }


    mysql_connect($servidorr, $usuarioo, $senhaa) or trigger_error(mysql_error());

    mysql_select_db($bdd) or trigger_error(mysql_error());

    $usuario = mysql_real_escape_string($_POST['usuario']);
    $senha = mysql_real_escape_string($_POST['senha']);
    $lang = mysql_real_escape_string($_POST['lang']);


    $sql = "SELECT `id`, `nome`, `nivel` FROM `usuarios` WHERE (`usuario` = '". $usuario ."') AND (`senha` = '". sha1($senha) ."') AND (`ativo` = 1) LIMIT 1";
    $updatelang = "UPDATE usuarios SET lang='$lang' WHERE usuario='$usuario'";
    $query = mysql_query($sql);
    if (mysql_num_rows($query) != 1) {

        echo "<script>alert('Oops! Looks like there is something wrong with your login! *perhaps a typo or you did not fill out the fields*'); location.href='geton'</script>"; exit;
    } else {

        $resultado = mysql_fetch_assoc($query);
      mysql_query($updatelang);


        if (!isset($_SESSION)) session_start();

        $_SESSION['UsuarioID'] = $resultado['id'];
        $_SESSION['UsuarioNome'] = $resultado['nome'];
      $_SESSION['usuario'] = $resultado['usuario'];
        $_SESSION['UsuarioNivel'] = $resultado['nivel'];
      $_SESSION['lang'] = $resultado['lang'];

        header("Location: http://mapmaking.zz.mu/pages/home"); exit;
    }

    ?>


Home file (these echos are just for testing and this is not the original file, the original one has the same php stuff, except the echo functions, those are in random lines):

<?php


if (!isset($_SESSION)) session_start();

  $tlang = $_SESSION['UsuarioLang'];
  $aclevel = $_SESSION['UsuarioNivel'];
  $nick = $_SESSION['UsuarioNome'];

$neededal = 1;
if (!isset($_SESSION['UsuarioID']) OR ($_SESSION['UsuarioNivel'] < $neededal)) {
    session_destroy();
    header("Location: http://inside.mapmaking.uk.to/geton"); exit;


}

session_start();

echo $tlang;
echo $aclevel;
echo $nick;
echo "$level$tlang$tlang";


?>

[this one basically start the session and check if the connected user acess level is 1]

Echo $tlang does not work! :( somehow it doesn’t, I have no idea why ;_;

Hope you guys help me, thank you!!

$_SESSION['lang'] != $_SESSION['UsuarioLang']

You assign a value to the first one, yet expect value from the second one.

$_SESSION['lang'] = $resultado['lang'];

$tlang = $_SESSION['UsuarioLang'];

Change this line:

$_SESSION['lang'] = $resultado['lang'];

to the following:

$_SESSION['UsuarioLang'] = $resultado['lang'];

You should also call session_start() without the isset check. Also, you should consider using && instead of AND and || instead of OR, as PHP has weird operator precedence rules (the assignment = has a higher precendence than either AND or OR).