For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > October 2006 > What's wrong hee?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What's wrong hee?
JohnDK

2006-10-13, 3:57 am

Hi friends.

I need some help here.

I have make this little piece i PHP, all files are where there shall be.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sporg fordeling</title>
</head>
<body>
<?php
$userlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
$userlang=substr($userlang,0,2);
switch($userlang) {
// Work so far, but the don't work.
case 'en': ("location: /en/index.php");break;
case 'de': ("location: /de/index.php");break;
default: ("location: /da/index.html");
}
?>
</body>
</html>

BR
John


Kimmo Laine

2006-10-13, 3:57 am

"JohnDK" <news@jal.as> wrote in message
news:egnkq3$uqg$1@news01.versatel.de...
> Hi friends.
>
> I need some help here.
>
> I have make this little piece i PHP, all files are where there shall be.
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> <title>Sporg fordeling</title>
> </head>
> <body>
> <?php
> $userlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
> $userlang=substr($userlang,0,2);
> switch($userlang) {
> // Work so far, but the don't work.
> case 'en': ("location: /en/index.php");break;
> case 'de': ("location: /de/index.php");break;
> default: ("location: /da/index.html");
> }
> ?>



1) just writing ("Location :...") does nothing. You propably wanted to call
header("Location...."); ?
2) you're starting output before setting the header, move the <?php ?> part
before you start outputting the html structure, right at the beginning of
the page, otherwise the header won't do anything.

HTH

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)


JohnDK

2006-10-13, 6:56 pm


"Kimmo Laine" <spam@outolempi.net> skrev i en meddelelse
news:3UIXg.5092$285.4536@reader1.news.jippii.net...
> "JohnDK" <news@jal.as> wrote in message
> news:egnkq3$uqg$1@news01.versatel.de...
>
>
> 1) just writing ("Location :...") does nothing. You propably wanted to
> call header("Location...."); ?
> 2) you're starting output before setting the header, move the <?php ?>
> part before you start outputting the html structure, right at the
> beginning of the page, otherwise the header won't do anything.
>
> HTH
>
> --
> "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
> http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
> spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)


Thanks a lot for the help.

John


.:[ ikciu ]:.

2006-10-13, 6:56 pm

Hmm JohnDK <news@jal.as> wrote:
> // Work so far, but the don't work.
> case 'en': ("location: /en/index.php");break;
> case 'de': ("location: /de/index.php");break;
> default: ("location: /da/index.html");


header('Location: ........');
and use ob_* function for this code


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this => mysql_query();


Jerry Stuckle

2006-10-13, 6:56 pm

..:[ ikciu ]:. wrote:
> Hmm JohnDK <news@jal.as> wrote:
>
>
>
> header('Location: ........');
> and use ob_* function for this code
>
>


He doesn't need the ob_ functions. In fact, he doesn't need any html at
all.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
.:[ ikciu ]:.

2006-10-13, 6:56 pm

Hmm Jerry Stuckle <jstucklex@attglobal.net> wrote:
> He doesn't need the ob_ functions. In fact, he doesn't need any html
> at all.



Yes and no :) My solution was written for that code what he showed. You
right he no need html to handle it ofc ...

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this => mysql_query();


MSB

2006-10-23, 6:57 pm

JohnDK wrote:
> Hi friends.
>
> I need some help here.
>
> I have make this little piece i PHP, all files are where there shall be.
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> <title>Sporg fordeling</title>
> </head>
> <body>
> <?php
> $userlang=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
> $userlang=substr($userlang,0,2);
> switch($userlang) {
> // Work so far, but the don't work.
> case 'en': ("location: /en/index.php");break;
> case 'de': ("location: /de/index.php");break;
> default: ("location: /da/index.html");
> }
> ?>
> </body>
> </html>
>
> BR
> John
>
>


what is this for...somone wanting to show a different page based on the
user's lang?
Koncept

2006-10-24, 3:56 am

In article <453D3915.5020306@asjflasjk.com>, MSB <asldfh@asjflasjk.com>
wrote:

>
> what is this for...somone wanting to show a different page based on the
> user's lang?


Location must be --> header("Location: /path");

<?php
$lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2);
$mapped = array('en','de','da');
if(in_array($lang,$mapped)){
header("Location: /$lang/index.php");
exit;
}
// default case
header("Location: /your/default/page");
exit;
?>

--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com