Page 1 of 1

Selecting a langauge for a website

Posted: Thu Feb 05, 2009 4:52 am
by Icethrill
So here's the thing got a piece of code that checks if your swedish or not. It worked before but now somehow it never loads the page. I tested the thing with echo's if it dont jump in the if correctly. It works and puts out the correct information. Have tried somethings to go around this but it dont work. So I am looking if you guys can see if somethings wrong with the code.

Code: Select all

<?php
    session_start();
    $tmp = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
    //$pos = strrpos($tmp, "-");
    $lang = substr($tmp, 0, 2);
 
    if(!isset($_SESSION['user_lang'])) {
        if($lang == "sv" || $lang == "SV") {
            header("location: se/");
            echo "hej";
        }
        $_SESSION['user_lang'] = $lang;
        echo "hej";
    }
    
    echo $lang;
    
?>

Re: Selecting a langauge for a website

Posted: Thu Feb 05, 2009 7:08 am
by Icethrill
anyone at all? this thing is giving me a headache! :banghead:

With header-list I get this information in the output:

Code: Select all

array(2) { [0]=>  string(23) "X-Powered-By: PHP/5.2.6" [1]=>  string(23) "Content-type: text/html" } ?


And with header-sent I get this output:

Code: Select all

Headers were already sent in /Users/maas/Sites/jamesway/index.php on line 1
I dont know if this is saying anything of whats wrong though... any ideas?