PDA

View Full Version : PHP stupid error...


rich w
April 12th, 2006, 17:36
Hi to all, i'm glad to join these forums they look very useful. Thanks to Jamie for introducing me to them.

I've got a really annoying PHP problem.

On my home server, the following code works:

while ($cur_row=mysql_fetch_assoc($result)) {
$_SESSION["hikes"][]=$cur_row["hikeid"];
$_SESSION["routedesc"][]=$cur_row["routedesc"];
}
//print_r($_SESSION);
for ($a=0; $a<count($_SESSION["hikes"]); $a++) {
$routedesc = substr($_SESSION["routedesc"][$a],0,11)."...";
}
The value of $routedesc outputs 3 times, eg. "abcdefg..." "dfsfsdfdsff..." dsfsddf..."

However, when I upload this to another server, I get this output:
"a" "." "."
If I then print the session, I get this:
[routedesc] => ....

Any ideas on what appears to be destroying the session?

Rich

Cameron
April 13th, 2006, 16:05
Make sure session_start(); is at the begining of your file(s), and you're not destroying the session anywhere via session_destroy() (except where appropriate).

There is a php.ini setting called session.auto_start that could be turned on locally, but is off on the remote server. Which could be causing your problem.

rich w
April 13th, 2006, 16:31
Make sure session_start(); is at the begining of your file(s), and you're not destroying the session anywhere via session_destroy() (except where appropriate).

There is a php.ini setting called session.auto_start that could be turned on locally, but is off on the remote server. Which could be causing your problem.

It was that setting :)

Thanks very much!