NYCPHP Meetup

[nycphp-talk] anyone have idea about the following warning message?

John Campbell jcampbell1 at gmail.com
Thu Apr 30 13:25:27 EDT 2009


DRY! DRY! DRY!

Try something like this:

$cart_keys = array(
'mouse_choice','monitor_choice','wifi_choice','subtotal','offsets','amount','desc','first_name','last_name','address','city','state','zip','phone','billeve','email','ship_to_first_name','ship_to_last_name','ship_to_address','ship_to_city','ship_to_state','ship_to_zip','shipday','card_num','exp_date','card_code');

foreach($cart_keys as $key) {
  if($_POST[$key])
    $_SESSION[$key] = $_POST[$key];
}

// load the keys as variables, not really needed because the values
already exist in  _SESSION.
extract(array_intersect_key($_SESSION,array_flip($cart_keys)));


Regards,
John Campbell

On Thu, Apr 30, 2009 at 10:47 AM, chad qian <nynj.tech at hotmail.com> wrote:
> I check
> link:http://www.spiration.co.uk/post/1231/Your%20script%20possibly%20relies%20on%20a%20session%20side-effect
> and make change. However,I still get the same warning message.
>
> I list my php code as the following:
> <?php
> session_start();
> $mouse_choice=$_POST["mouse_choice"];
> $monitor_choice=$_POST["monitor_choice"];
> $wifi_choice=$_POST["wifi_choice"];
> $subtotal=$_POST["subtotal"];
> $offsets=$_POST["offsets"];
> $amount=$_POST["amount"];
> $desc=$_POST["desc"];
> $first_name=$_POST["first_name"];
> $last_name=$_POST["last_name"];
> $address=$_POST["address"];
> $city=$_POST["city"];
> $state=$_POST["state"];
> $zip=$_POST["zip"];
> $phone=$_POST["phone"];
> $billeve=$_POST["billeve"];
> $email=$_POST["email"];
> $ship_to_first_name=$_POST["ship_to_first_name"];
> $ship_to_last_name=$_POST["ship_to_last_name"];
> $ship_to_address=$_POST["ship_to_address"];
> $ship_to_city=$_POST["ship_to_city"];
> $ship_to_state=$_POST["ship_to_state"];
> $ship_to_zip=$_POST["ship_to_zip"];
> $shipday=$_POST["shipday"];
> $card_num=$_POST["card_num"];
> $exp_date=$_POST["exp_date"];
> $card_code=$_POST["card_code"];
>
>
>
> if($_POST["mouse_choice"])
> $_SESSION["mouse_choice"]=$mouse_choice;
> else
> $mouse_choice=$_SESSION["mouse_choice"];
>
> if($_POST["monitor_choice"])
> $_SESSION["monitor_choice"]=$monitor_choice;
> else
> $monitor_choice=$_SESSION["monitor_choice"];
>
> if($_POST["wifi_choice"])
> $_SESSION["wifi_choice"]=$wifi_choice;
> else
> $wifi_choice=$_SESSION["wifi_choice"];
>
> if($_POST["subtotal"])
> $_SESSION["subtotal"]=$subtotal;
> else
> $subtotal=$_SESSION["subtotal"];
>
> if($_POST["offsets"])
> $_SESSION["offsets"]=$offsets;
> else
> $offsets=$_SESSION["offsets"];
>
> if($_POST["amount"])
> $_SESSION["amount"]=$amount;
> else
> $amount=$_SESSION["amount"];
> $sum=$subtotal;
>
> if($_POST["desc"])
> $_SESSION["desc"]=$desc;
> else
> $desc=$_SESSION["desc"];
>
> if($_POST["first_name"])
> $_SESSION["first_name"]=$first_name;
> else
> $first_name=$_SESSION["first_name"];
>
> if($_POST["last_name"])
> $_SESSION["last_name"]=$last_name;
> else
> $last_name=$_SESSION["last_name"];
>
> if($_POST["address"])
> $_SESSION["address"]=$address;
> else
> $address=$_SESSION["address"];
>
> if($_POST["city"])
> $_SESSION["city"]=$city;
> else
> $city=$_SESSION["city"];
>
> if($_POST["state"])
> $_SESSION["state"]=$sate;
> else
> $state=$_SESSION["state"];
>
> if($_POST["zip"])
> $_SESSION["zip"]=$zip;
> else
> $zip=$_SESSION["zip"];
>
> if($_POST["phone"])
> $_SESSION["phone"]=$phone;
> else
> $phone=$_SESSION["phone"];
>
> if($_POST["billeve"])
> $_SESSION["billeve"]=$billeve;
> else
> $billeve=$_SESSION["billeve"];
>
> if($_POST["email"])
> $_SESSION["email"]=$email;
> else
> $email=$_SESSION["email"];
>
> if($_POST["ship_to_first_name"])
> $_SESSION["ship_to_first_name"]=$ship_to_first_name;
> else
> $ship_to_first_name=$_SESSION["ship_to_first_name"];
>
> if($_POST["ship_to_last_name"])
> $_SESSION["ship_to_last_name"]=$ship_to_last_name;
> else
> $ship_to_last_name=$_SESSION["ship_to_last_name"];
>
> if($_POST["ship_to_address"])
> $_SESSION["ship_to_address"]=$ship_to_address;
> else
> $ship_to_address=$_SESSION["ship_to_address"];
>
> if($_POST["ship_to_city"])
> $_SESSION["ship_to_city"]=$ship_to_city;
> else
> $ship_to_city=$_SESSION["ship_to_city"];
>
> if($_POST["ship_to_state"])
> $_SESSION["ship_to_state"]=$ship_to_state;
> else
> $ship_to_state=$_SESSION["ship_to_state"];
>
> if($_POST["ship_to_zip"])
> $_SESSION["ship_to_zip"]=$ship_to_zip;
> else
> $ship_to_zip=$_SESSION["ship_to_zip"];
>
> if($_POST["shipday"])
> $_SESSION["shipday"]=$shipday;
> else
> $shipday=$_SESSION["shipday"];
>
> if($_POST["card_num"])
> $_SESSION["card_num"]=$card_num;
> else
> $card_num=$_SESSION["card_num"];
>
> if($_POST["exp_date"])
> $_SESSION["exp_date"]=$exp_date;
> else
> $exp_date=$_SESSION["exp_date"];
>
> if($_POST["card_code"])
> $_SESSION["card_code"]=$card_code;
> else
> $card_code=$_SESSION["card_code"];
>
> ?>
>
> Any more help?Many thanks!
>
> chad
>
>> Date: Wed, 29 Apr 2009 23:33:20 -0400
>> From: tomsartain at gmail.com
>> To: talk at lists.nyphp.org
>> Subject: Re: [nycphp-talk] anyone have idea about the following warning
>> message?
>>
>> Found this from googling the first sentance:
>>
>> http://www.spiration.co.uk/post/1231/Your%20script%20possibly%20relies%20on%20a%20session%20side-effect
>>
>> Apparently you're trying to assign a global variable into the session
>> directly. Of course, if you could provide some sort of code, we could
>> help out a bit more.
>>
>> You say you've got this isolated down to one PHP page... have you
>> tried working down the code line-by-line to see what ends up throwing
>> the error?
>>
>> On 4/29/09, chad qian <nynj.tech at hotmail.com> wrote:
>> >
>> > I always get this warning message on one php page:
>> >
>> > "
>> >
>> > Warning: Unknown: Your script possibly relies on a session side-effect
>> > which
>> > existed until PHP 4.2.3. Please be advised that the session extension
>> > does
>> > not consider global variables as a source of data, unless
>> > register_globals
>> > is enabled. You can disable this functionality and this warning by
>> > setting
>> > session.bug_compat_42 or session.bug_compat_warn to off, respectively.
>> > in
>> > Unknown on line 0
>> >
>> > "
>> >
>> > How to fix this issue?php problem or apache web server problem?I have no
>> > clue.
>> >
>> >
>> >
>> > Thanks in advance!
>> >
>> >
>> >
>> > chad
>> >
>> > _________________________________________________________________
>> > Rediscover Hotmail®: Get e-mail storage that grows with you.
>> >
>> > http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009
>> _______________________________________________
>> New York PHP User Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/show_participation.php
>
> ________________________________
> Rediscover Hotmail®: Get e-mail storage that grows with you. Check it out.
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>



More information about the talk mailing list