[FX.php List] php 5 problems: I have tried to copy my existing scripts to php5 enabled servers

Dale Bengston dbengston at preservationstudio.com
Mon Mar 5 10:27:13 MST 2007


I have no problems with multi-level arrays in $_SESSION. I think your  
problem is related to whether those $_SESSION values, nested or  
otherwise, are actually set when you try to evaluate them in your if  
statement. What happens when you print_r($_SESSION) above that if  
statement?

Dale

PS I also have big trouble with PHP 5 if I use <? to start a block of  
PHP code instead of <?php.

On Mar 5, 2007, at 11:11 AM, Gjermund Gusland Thorsen wrote:

> Hmm I run into this problem with my login check that is something  
> like this:
>
> <?
> session_start();
> include_once($_SERVER['DOCUMENT_ROOT'] . "/projectkey.php");
> if( $_SESSION[$projectKey]['user']['idSavedString'] != sha1(
> $_SERVER['REMOTE_ADDR'] . '/' .
> $_SESSION[$projectKey]['shipowner']['id'] ) ) {
>        header( "Location: /" );
>        exit;
> }
>
> as you see there is 2 or more nested arrays in my _SESSION vars,
> and that seems to be a problem with php5; part of the known stack
> problem perhaps?
>
> ggt667
>
> On 3/5/07, Carl Anderson <Carl.Anderson at asu.edu> wrote:
>> Error, or warn?  I'm using it now, and I believe we're running 5  
>> in-house,
>> but I haven't seen anything bomb.
>>
>> (Mind you, most of what my $var happens to be is $_POST stuff  
>> anyhow, so
>> it's pretty well guaranteed to be set, by me.)
>>
>> --
>> Carl Anderson
>> Technical Support Analyst
>> Distance Learning
>> Herberger College of Fine Arts
>> Arizona State University
>> http://herbergeronline.asu.edu
>>
>>
>> > From: Dale Bengston <dbengston at preservationstudio.com>
>> > Reply-To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>> > Date: Mon, 5 Mar 2007 10:21:22 -0600
>> > To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>> > Subject: Re: [FX.php List] php 5 problems: I have tried to copy  
>> my existing
>> > scripts to php5 enabled servers
>> >
>> > However...
>> >
>> > $var = trim($var);
>> >
>> > ...will error under PHP 5 if $var is not set.
>> >
>> > Dale
>> >
>> >
>> > On Mar 5, 2007, at 9:57 AM, Carl Anderson wrote:
>> >
>> >> Regarding isset() ...  Try empty($var) instead.  It returns false
>> >> when you'd
>> >> expect it to (for the most part), even when the variable exists.
>> >>
>> >> What I'll often do is something like this, just to be safe:
>> >>
>> >> $var = trim($var);
>> >> if ( empty($var) ) {
>> >>     // do something if $var is empty
>> >>     ...
>> >> }
>> >>
>> >> --
>> >> Carl Anderson
>> >> Technical Support Analyst
>> >> Distance Learning
>> >> Herberger College of Fine Arts
>> >> Arizona State University
>> >> http://herbergeronline.asu.edu
>> >>
>> >>
>> >>> From: Bob Patin <bob at patin.com>
>> >>> Reply-To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>> >>> Date: Mon, 5 Mar 2007 09:48:44 -0600
>> >>> To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>> >>> Subject: Re: [FX.php List] php 5 problems: I have tried to  
>> copy my
>> >>> existing
>> >>> scripts to php5 enabled servers
>> >>>
>> >>> I've always tested to make sure that not only is there a session
>> >>> variable by that name, but also that it's not empty, by using
>> >>>
>> >>> if(strlen($_SESSION['myvar'])>0)
>> >>>
>> >>> Probably an easier way, but it works fine for me so that's how  
>> I've
>> >>> been doing it...
>> >>>
>> >>> I used to use isset, but sometimes I found that a variable was  
>> there,
>> >>> but there was nothing in it...
>> >>>
>> >>> Bob Patin
>> >>> Longterm Solutions
>> >>> bob at longtermsolutions.com
>> >>> 615-333-6858
>> >>> http://www.longtermsolutions.com
>> >>>
>> >>>    CONTACT US VIA INSTANT MESSAGING:
>> >>>       AIM or iChat: longterm1954
>> >>>       Yahoo: longterm_solutions
>> >>>       MSN: tech at longtermsolutions.com
>> >>>       ICQ: 159333060
>> >>>
>> >>>
>> >>> On Mar 5, 2007, at 9:00 AM, Dale Bengston wrote:
>> >>>
>> >>>> With PHP 4, I used to do a lot of evaluations like
>> >>>>
>> >>>> if ($_SESSION['whatever'])
>> >>>>
>> >>>> ...using the presence or absence of a variable to decide action.
>> >>>> PHP 5 requires more explicit references, like
>> >>>>
>> >>>> if (isset($_SESSION['whatever']))
>> >>>> if (!empty($_SESSION['whatever']))
>> >>>>
>> >>>> ...so I can't be sloppy any more. Maybe you're running into  
>> this?
>> >>>>
>> >>>> Dale
>> >>>>
>> >>>>
>> >>>> On Mar 5, 2007, at 6:30 AM, Gjermund Gusland Thorsen wrote:
>> >>>>
>> >>>>> php 5 problems: I have tried to copy my existing scripts to  
>> php5
>> >>>>> enabled servers
>> >>>>>
>> >>>>> It has problems, especially with ifs while traversing arrays in
>> >>>>> _REQUEST and _SESSION
>> >>>>>
>> >>>>> anyone else encountered this?
>> >>>>>
>> >>>>> ggt667
>> >>>>> _______________________________________________
>> >>>>> FX.php_List mailing list
>> >>>>> FX.php_List at mail.iviking.org
>> >>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>> >>>>
>> >>>> _______________________________________________
>> >>>> FX.php_List mailing list
>> >>>> FX.php_List at mail.iviking.org
>> >>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>> >>>
>> >>> _______________________________________________
>> >>> FX.php_List mailing list
>> >>> FX.php_List at mail.iviking.org
>> >>> http://www.iviking.org/mailman/listinfo/fx.php_list
>> >>
>> >> _______________________________________________
>> >> FX.php_List mailing list
>> >> FX.php_List at mail.iviking.org
>> >> http://www.iviking.org/mailman/listinfo/fx.php_list
>> >
>> > _______________________________________________
>> > FX.php_List mailing list
>> > FX.php_List at mail.iviking.org
>> > http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list