Jump to content


Photo

Page loads only after refresh


  • Please log in to reply
5 replies to this topic

#1 Apyvala

Apyvala
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 22 April 2006 - 03:13 PM

Hi,

i have a website on three speeches - Lithuania ( lt ), English ( en ) and Russian ( ru ). Website on one server works perfect, but on another server not.

In index file i have such code:

if (!session_is_registered("speech")) {
if ($_SESSION['speech'] == "") {
session_register("speech");
$_SESSION['speech'] = "lt";
}

that is, default speech is lt. Moreower i have three links:

<a href="change_speech.php?speech=lt" class="speech">LT</a> <a href="change_speech.php?speech=en" class="speech">EN</a> <a href="change_speech.php?speech=ru" class="speech">RU</a>

My change_speech.php file looks:

<?php
session_start();

$_SESSION['speech'] = $_GET['speech'];

header ("Location: index.php");
?>


The problem: when i push on links "LT", "EN" or "RU" i see white page, i need to push F5 ( to refresh page ) than i could see the page.
This problem occurs only on one server, on another server i haven't such problem.

Any ideas?

#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 23 April 2006 - 03:47 AM

maybe it has something to do with the way your php.ini file is configured but I don't know how to help with that.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#3 mb81

mb81
  • Members
  • PipPipPip
  • Advanced Member
  • 120 posts

Posted 23 April 2006 - 03:51 AM

[!--quoteo(post=367461:date=Apr 22 2006, 10:13 AM:name=Apyvala)--][div class=\'quotetop\']QUOTE(Apyvala @ Apr 22 2006, 10:13 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hi,

i have a website on three speeches - Lithuania ( lt ), English ( en ) and Russian ( ru ). Website on one server works perfect, but on another server not.

In index file i have such code:

if (!session_is_registered("speech")) {
if ($_SESSION['speech'] == "") {
session_register("speech");
$_SESSION['speech'] = "lt";
}

that is, default speech is lt. Moreower i have three links:

<a href="change_speech.php?speech=lt" class="speech">LT</a> <a href="change_speech.php?speech=en" class="speech">EN</a> <a href="change_speech.php?speech=ru" class="speech">RU</a>

My change_speech.php file looks:

<?php
session_start();

$_SESSION['speech'] = $_GET['speech'];

header ("Location: index.php");
?>
The problem: when i push on links "LT", "EN" or "RU" i see white page, i need to push F5 ( to refresh page ) than i could see the page.
This problem occurs only on one server, on another server i haven't such problem.

Any ideas?
[/quote]


try exit(); after the header call in change_speech.php. I have found that you have to force some browsers to do that header function.

#4 Apyvala

Apyvala
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 23 April 2006 - 01:27 PM

Thank you for suggestions. But my website doesn't work well after the you suggested changes.

I has perceived an interesting thing. I am using:

HTML code:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


then i change it to:

<meta http-equiv="Content-Type" content="text/html; charset=win-1257" />


Than the website works well. Hmmm... it is very interesting for me.

win-1257 - Lithuanian encoding

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 April 2006 - 01:52 PM

When using sessions, make sure you have
<?php session_start(); ?>
at the start of each script where sessions are being used. Do not use the functions session_is_registered() and session_register(). Instead use
<?php if (!isset($_SESSION['var])) ?>
for
<?php if (!session_is_registered('var') ?>

So your index.php code should look something like:
<?php
session_start();
if (!isset($_SESSION['speech']) || (isset($_SESSION['speech']) && $_SESSION['speech'] == '')))
     $_SESSION['speech'] = 'lt';
?>

In your change_speech.php code, you should do something like:
<?php
session_start();
$_SESSION['speech'] = (isset($_GET['speech']))?$_GET['speech']:'lt';
?>

Ken

#6 Apyvala

Apyvala
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 24 April 2006 - 11:35 AM

Thank you very much for much for help.
My page works perfect when i replace:

session_start();

to

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users