Annoying PHP problem

Associate
Joined
30 Dec 2005
Posts
415
I've got a really annoying PHP problem.

On my home server, the following code works:
Code:
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?
 
Code:
while ($row = mysql_fetch_assoc($result)) {
	$_SESSION['hikes'][]		= $row['hikeid'];
	$_SESSION['routedesc'][]	= $row['routedesc'];
	
	echo substr($row['routedesc'], 0, 11).'...';
}

Why do two loops :confused:
 
robmiller said:
Code:
while ($row = mysql_fetch_assoc($result)) {
	$_SESSION['hikes'][]		= $row['hikeid'];
	$_SESSION['routedesc'][]	= $row['routedesc'];
	
	echo substr($row['routedesc'], 0, 11).'...';
}

Why do two loops :confused:

Good point :eek:
 
Back
Top Bottom