[PHP] this code unsets $_SESSION['editor'] but doesn't touch any other session variables

2003-09-07 Thread anders thoresson
Hi,

I've had troubles with an application that randomly (until now) unsets the 
session variable $_SESSION['editor']. I've hunted through all my code and 
finally managed to rule out everything else than the following couple of 
lines.

It unsets the session variable $_SESSION['editor'], but leaving others, 
like $_SESSION['admin'] untouched. At the first debug, I get Admin: Y 
Editor: Y printed (which is the way I suppose things to be), but at the 
second debug I just get Admin: Y Editor:.

I can't find the error though. Any input appreciated!

Best regards,

  Anders Thoresson

?php
// Debug, echoing session variables
echo (Admin:  );
echo ($_SESSION['admin']);
echo (  Editor:  );
echo ($_SESSION['editor']);
$issuequery = SELECT un_issue.i_date, un_issue.i_editor FROM un_issue 
WHERE un_issue.i_date  CURDATE() ORDER BY i_date ASC;
$issueresult = mysql_query($issuequery);
$editorquery = SELECT u_uname, u_id FROM un_user WHERE u_editor = 'Y';
$editorresult = mysql_query($editorquery);
?
form action=issue_save_changes.php method=post
table cellspacing=0
?php
// Initate counter for table background
$background = 1;
// Loop through all coming issues
while ($issue = mysql_fetch_row($issueresult))
{
	mysql_data_seek($editorresult, 0);
	if (is_even($background))
	{
		$row_background = even;
	}
	else
	{
		$row_background = odd;
	}
	?
	tr class=?php echo $row_background; ?
		td class=borderlessinput name=issue[] type=hidden value=?php 
echo $issue[0]; ? ?php echo format_date($issue[0]); ?/td
		td class=borderlessselect name=issue_editor[]
		?php
		// If editor isn't entered, highlight Inte bestämt
		if (!isset($issue[1]))
		{
			?
			option value=NULL selectedInte bestämt
			?php
			while ($editor = mysql_fetch_row($editorresult))
			{
?
option value=?php echo $editor[1] ??php echo $editor[0]; ?
?php
			}
		} 		// If an editor is entered, highlight her/him
		else
		{
			?
			option value=NULLInte bestämt
			?php
			while ($editor = mysql_fetch_row($editorresult))
			{
			if ($editor[1] == $issue[1])
			{
?
option value=?php echo $editor[1] ? selected?php echo 
$editor[0]; ?
?php
			}
			else
			{
?
option value=?php echo $editor[1] ??php echo $editor[0]; ?
?php
			}
		}
	}
	?
	/select
	/tr
	?php
	++$background;
}
?
/table
input type=submit value=Spara ändringar
/form
?php
// Debug, echoing session variables
echo (Admin:  );
echo ($_SESSION['admin']);
echo (  Editor:  );
echo ($_SESSION['editor']);

--
anders thoresson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] this code unsets $_SESSION['editor'] but doesn't touch any other session variables

2003-09-07 Thread John W. Holmes
anders thoresson wrote:

Hi,

I've had troubles with an application that randomly (until now) unsets 
the session variable $_SESSION['editor']. I've hunted through all my 
code and finally managed to rule out everything else than the following 
couple of lines.

It unsets the session variable $_SESSION['editor'], but leaving others, 
like $_SESSION['admin'] untouched. At the first debug, I get Admin: Y 
Editor: Y printed (which is the way I suppose things to be), but at the 
second debug I just get Admin: Y Editor:.
[snip]
while ($editor = mysql_fetch_row($editorresult))
[snip]

You more than likely have register globals ON, so by setting $editor to 
some value above, you are also changing the value of $_SESSION['editor'].

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals - www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] this code unsets $_SESSION['editor'] but doesn't touch any other session variables

2003-09-07 Thread anders thoresson
You more than likely have register globals ON, so by setting $editor to 
some value above, you are also changing the value of $_SESSION['editor'].
Yes! Settings at ISP was with globals on, but at my local server they were 
off. Which added quite a lot to my confusion.

Thanks!

--
anders thoresson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] this code unsets $_SESSION['editor'] but doesn't touch any other session variables

2003-09-07 Thread anders thoresson
 while ($editor = mysql_fetch_row($editorresult))
How about changing from an assignment operator = to a comparison
operator ==.
No. I want to step through each and every one of the rows in the result 
set, and that's done that way.

--
anders thoresson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php