Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2004
    Posts
    14

    Unanswered: variable isnot be accessed

    i have a problem! i am trying to use session variable.i am simply trying to access a session variable stored in one page from next page

    i wrote a program..the code goes like this.

    <?php
    session_start();
    $save_this=19;
    $_SESSION['save_this']=$save_this;
    if($_SESSION['save_this']=="19")
    {
    header("location:two.php");
    }
    ?>

    and in the two.php page, the code is like this

    <?php
    session_start();
    $saved_previous=$_SESSION['save_this'];
    echo ($saved_previous);
    ?>

    but when i run it..in first time it always shows error
    Notice: Undefined index: save_this in two.php on line 4

    however when i run the page second time in the same explorer window it works fine...that is it displays 19...i dont know what is going wrong!!
    please help me!!!!

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    I guess there would be some problem of caching.
    This code is work fine on my system.

    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  3. #3
    Join Date
    Oct 2004
    Posts
    14
    what is caching and how can we fix bug with it ?

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    First try this.. ..
    In your php.ini file find this line
    error_reporting
    for this variablemake the value as
    error_reporting= E_ALL & ~E_NOTICE
    now this will not display the notice which are not required.
    Lets try this and let me know ... if you are getting the error or not getting the output.

    Regards
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  5. #5
    Join Date
    Oct 2004
    Posts
    14
    In php.inc file, by default, the value of error_reporting was
    error_reporting= E_ALL & ~E_NOTICE
    so i didnot make any change. but this still doesnot work out

    smeeta

  6. #6
    Join Date
    Oct 2004
    Posts
    14
    hello!!

    can you please test the code in your pc..i wanted to conform if the code is wrong or some other problem exist. i would appreciate your help.


    smeeta

  7. #7
    Join Date
    Oct 2004
    Posts
    14
    oh oh..rajesh r r said it works fine in his system..so this is for sure that the code is right..so what may be the other problem...any idea????

    smeeta

  8. #8
    Join Date
    Oct 2004
    Posts
    14
    i installed my IIS server and php again and tried, but still it doesnot work out. i am using IIS server and php 4.3.6...any idea?

  9. #9
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    I works for me in the same configuration. I am using IIS and PHP 5. But I tried this with php4.3 and apache 2 . It is working fine. So the code is ok. Try commenting the error_reporting in the php.ii file.

    Regards
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  10. #10
    Join Date
    Oct 2004
    Posts
    14
    i corrected the value of error_reporting as error_reporting= E_ALL & ~E_NOTICE ,the error messege is not shown now, but a blank screen is displayed in the first attempt to run it, and in the second run from the in same explorer window, every thing works fine.

    smeeta

  11. #11
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    Just check these values in the php.ini file
    session.auto_start = 0
    session.name = PHPSESSID
    session.gc_probability = 1
    session.gc_divisor = 1000
    session.cache_limiter = nocache
    session.use_trans_sid = 0

    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  12. #12
    Join Date
    Oct 2004
    Posts
    14
    other everyvariable were set as you said, only the change required was on
    session.gc_divisor which was set 100 so i made it to
    session.gc_divisor = 1000, but this didnot help either....


    smeeta

  13. #13
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    which is the browser you are using?
    Which is the IIS version? How did you installed the php there?
    What happened when you comment the session_start() in the page two.php
    I don't why this is happeneing but now you can just do a hit or miss..

    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •