Professional Web Applications Themes

My PHP Sessions dont work - PHP Development

Please can someone help me with this. I have a nice simple test for a php session to see if my setup is ok, but it does not pass vars correctly. Setup: WinXP, Apache 1.3, PHP 4.3.3. I ahve the setting in php.ini for session.save.path = "c:\php\temp\" It does create session files in here but does not pass the vars to the next page. My php.ini is the php.ini-recommended with just the above bit changed. This is my test: sessiontest1.php: <?php session_start(); $_SESSION['session_var']= "testing"; ?> <html> <head><title>Testing Sessions page 1</title></head> <body> <?php echo "This is a test of the sessions ...

  1. #1

    Default My PHP Sessions dont work

    Please can someone help me with this. I have a nice simple test for a php
    session to see if my setup is ok, but it does not pass vars correctly.

    Setup:
    WinXP, Apache 1.3, PHP 4.3.3.
    I ahve the setting in php.ini for session.save.path = "c:\php\temp\"

    It does create session files in here but does not pass the vars to the next
    page.

    My php.ini is the php.ini-recommended with just the above bit changed.

    This is my test:

    sessiontest1.php:
    <?php
    session_start();
    $_SESSION['session_var']= "testing";
    ?>
    <html>
    <head><title>Testing Sessions page 1</title></head>
    <body>
    <?php
    echo "This is a test of the sessions feature.
    <form action='sessionTest2.php'' method='post'>
    <input type='text' name='form_var' value='testing'>
    <input type='submit' value='go to next page'>
    </form>";
    ?>
    </body>

    sessiontest2.php:

    <?php
    session_start();
    ?>
    <html>
    <head><title>Testing Sessions page 2</title></head>
    <body>
    <?php
    /* echo "session_var = $_SESSION['session_var']<br>\n";*/
    echo "form_var = $_SESSION['form_var']<br>\n";
    ?>
    </body>
    </html>



    Sorry about the font change - cannot change it back!!

    Please do help me as i cannot solve this myself and have tried everything
    from different websites.



    Thanks

    Dan




    Dan Walker Guest

  2. #2

    Default Re: My PHP Sessions dont work

    On Sat, 8 Nov 2003 14:11:44 +0000 (UTC), "Dan Walker" <dan.j.walkertalk21.com>
    wrote:
    >Please can someone help me with this. I have a nice simple test for a php
    >session to see if my setup is ok, but it does not pass vars correctly.
    >
    >Setup:
    >WinXP, Apache 1.3, PHP 4.3.3.
    >I ahve the setting in php.ini for session.save.path = "c:\php\temp\"
    >
    >It does create session files in here but does not pass the vars to the next
    >page.
    >
    >My php.ini is the php.ini-recommended with just the above bit changed.
    >
    >This is my test:
    >
    >sessiontest1.php:
    ><?php
    >session_start();
    >$_SESSION['session_var']= "testing";
    Here you set session_var as a session variable.
    >sessiontest2.php:
    >
    ><?php
    >session_start();
    >?>
    ><html>
    ><head><title>Testing Sessions page 2</title></head>
    ><body>
    ><?php
    >/* echo "session_var = $_SESSION['session_var']<br>\n";*/
    Why's this commented out?
    >echo "form_var = $_SESSION['form_var']<br>\n";
    Here you try and print out form_var, which wasn't set as a session variable.

    Also you don't use single quotes on array subscripts inside double quotes;
    this results in a p error - unless you put braces around it as in:

    echo "form_var = {$_SESSION['form_var']}<br>\n";

    But what you actually want is:

    echo "session_var = {$_SESSION['session_var']}<br>\n";

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  3. #3

    Default Re: My PHP Sessions dont work

    ok, sorry for the silly bits in that code.

    I commented out the first bit as i get an error. I have now corrected
    sessiontest2.php as follows:

    <?php
    session_start();
    ?>
    <html>
    <head><title>Testing Sessions page 2</title></head>
    <body>
    <?php
    echo "form_var = $_SESSION['session_var']<br>\n";
    ?>
    </body>
    </html>

    I still get a blank page with no text at all!! If i run this in an IDE dubug
    thing like PHPEd I get the following error:

    P error: p error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
    T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache
    Group\Apache\htdocs\php_place\sessionTest2.php on line 9

    I do not understand what this means. I get a blank page when running from
    the server and this when i run in PHPEd. This error is why i commented out
    the line in the other script. I have E_ALL set for error reporting in
    php.ini, but only get this error in phpED, not IE6...
    "Andy Hassall" <andyandyh.co.uk> wrote in message
    news:nf3qqv4rd9926quj04khfqsliogbgnj4f64ax.com...
    > On Sat, 8 Nov 2003 14:11:44 +0000 (UTC), "Dan Walker"
    <dan.j.walkertalk21.com>
    > wrote:
    >
    > >Please can someone help me with this. I have a nice simple test for a php
    > >session to see if my setup is ok, but it does not pass vars correctly.
    > >
    > >Setup:
    > >WinXP, Apache 1.3, PHP 4.3.3.
    > >I ahve the setting in php.ini for session.save.path = "c:\php\temp\"
    > >
    > >It does create session files in here but does not pass the vars to the
    next
    > >page.
    > >
    > >My php.ini is the php.ini-recommended with just the above bit changed.
    > >
    > >This is my test:
    > >
    > >sessiontest1.php:
    > ><?php
    > >session_start();
    > >$_SESSION['session_var']= "testing";
    >
    > Here you set session_var as a session variable.
    >
    > >sessiontest2.php:
    > >
    > ><?php
    > >session_start();
    > >?>
    > ><html>
    > ><head><title>Testing Sessions page 2</title></head>
    > ><body>
    > ><?php
    > >/* echo "session_var = $_SESSION['session_var']<br>\n";*/
    >
    > Why's this commented out?
    >
    > >echo "form_var = $_SESSION['form_var']<br>\n";
    >
    > Here you try and print out form_var, which wasn't set as a session
    variable.
    >
    > Also you don't use single quotes on array subscripts inside double
    quotes;
    > this results in a p error - unless you put braces around it as in:
    >
    > echo "form_var = {$_SESSION['form_var']}<br>\n";
    >
    > But what you actually want is:
    >
    > echo "session_var = {$_SESSION['session_var']}<br>\n";
    >
    > --
    > Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    > Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])

    Dan Walker Guest

  4. #4

    Default Re: My PHP Sessions dont work

    Dan Walker wrote:
    > ok, sorry for the silly bits in that code.
    >
    > I commented out the first bit as i get an error. I have now corrected
    > sessiontest2.php as follows:
    >
    > <?php
    > session_start();
    > ?>
    > <html>
    > <head><title>Testing Sessions page 2</title></head>
    > <body>
    > <?php
    > echo "form_var = $_SESSION['session_var']<br>\n";
    > ?>
    > </body>
    > </html>
    >
    > I still get a blank page with no text at all!! If i run this in an IDE dubug
    > thing like PHPEd I get the following error:
    >
    > P error: p error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
    > T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache
    > Group\Apache\htdocs\php_place\sessionTest2.php on line 9
    maybe cuz you didn't read :
    >> Also you don't use single quotes on array subscripts inside double
    quotes;
    this results in a p error - unless you put braces around it as in:
    <<

    Iky Guest

  5. #5

    Default Re: My PHP Sessions dont work

    On Sat, 8 Nov 2003 16:54:44 +0000 (UTC), "Dan Walker" <dan.j.walkertalk21.com>
    wrote:
    >I commented out the first bit as i get an error. I have now corrected
    >sessiontest2.php as follows:
    >
    ><?php
    > session_start();
    >?>
    ><html>
    ><head><title>Testing Sessions page 2</title></head>
    ><body>
    ><?php
    > echo "form_var = $_SESSION['session_var']<br>\n";
    Reread my reply above - this is wrong. You want any of:

    echo "form_var = {$_SESSION['session_var']}<br>\n";
    echo "form_var = ".$_SESSION['session_var']."<br>\n";
    echo "form_var = $_SESSION[session_var]<br>\n";
    >P error: p error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
    >T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache
    >Group\Apache\htdocs\php_place\sessionTest2.php on line 9
    [url]http://www.php.net/manual/en/language.types.string.php#language.types.string.sy ntax.double[/url]

    [url]http://www.php.net/manual/en/language.types.array.php#language.types.array.foo-bar[/url]
    (see fourth code example section)

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

Similar Threads

  1. why dont it work
    By hippihop in forum Macromedia Flash Player
    Replies: 1
    Last Post: March 20th, 02:51 AM
  2. #40487 [NEW]: Sessions dont work, MySQL fails and various bugs
    By splith at helper3000 dot net in forum PHP Bugs
    Replies: 2
    Last Post: February 15th, 10:30 AM
  3. it just dont work
    By prmanoel in forum Macromedia Flash Player
    Replies: 0
    Last Post: January 28th, 06:19 PM
  4. Dont work! Please help!
    By Sandro Haag in forum Macromedia Flash Flashcom
    Replies: 6
    Last Post: December 6th, 03:45 PM
  5. why dont my plugins work?
    By Cydne Chartier in forum Adobe Photoshop Elements
    Replies: 1
    Last Post: July 8th, 02:25 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139