Ask a Question related to PHP Development, Design and Development.
-
Dan Walker #1
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
-
why dont it work
errr hi i can get to work on my internet but if i playsumin local to my pc it keeps using flash player 7 -
#40487 [NEW]: Sessions dont work, MySQL fails and various bugs
From: splith at helper3000 dot net Operating system: Windows Server 2003 PHP version: 4.4.5 PHP Bug Type: *General Issues... -
it just dont work
please, some body can help me a box in my site should conect to a weather forecast, but it never conects.... what should I do? -
Dont work! Please help!
Hello! First of all I wanna say thanks for all who will answer my dumm question! PS: Sorry about my English :) Im a begginer in Flash Media... -
why dont my plugins work?
Just moved up to OSX, so 'scuse the dummy question, please. Is there any reason not to install Elements2 in both OSX and OS9 environments? Can you... -
Andy Hassall #2
Re: My PHP Sessions dont work
On Sat, 8 Nov 2003 14:11:44 +0000 (UTC), "Dan Walker" <dan.j.walker@talk21.com>
wrote:
Here you set session_var as a session variable.>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";
Why's this commented out?>sessiontest2.php:
>
><?php
>session_start();
>?>
><html>
><head><title>Testing Sessions page 2</title></head>
><body>
><?php
>/* echo "session_var = $_SESSION['session_var']<br>\n";*/
Here you try and print out form_var, which wasn't set as a session variable.>echo "form_var = $_SESSION['form_var']<br>\n";
Also you don't use single quotes on array subscripts inside double quotes;
this results in a parse 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 (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
Andy Hassall Guest
-
Dan Walker #3
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:
Parse error: parse 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" <andy@andyh.co.uk> wrote in message
news:nf3qqv4rd9926quj04khfqsliogbgnj4f6@4ax.com...<dan.j.walker@talk21.com>> On Sat, 8 Nov 2003 14:11:44 +0000 (UTC), "Dan Walker"next> 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 thevariable.>> >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 sessionquotes;>
> Also you don't use single quotes on array subscripts inside double> this results in a parse 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 (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
> Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
Dan Walker Guest
-
Iky #4
Re: My PHP Sessions dont work
Dan Walker wrote:
maybe cuz you didn't read :> 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:
>
> Parse error: parse 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
quotes;>> Also you don't use single quotes on array subscripts inside double
this results in a parse error - unless you put braces around it as in:
<<
Iky Guest
-
Andy Hassall #5
Re: My PHP Sessions dont work
On Sat, 8 Nov 2003 16:54:44 +0000 (UTC), "Dan Walker" <dan.j.walker@talk21.com>
wrote:
Reread my reply above - this is wrong. You want any of:>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";
echo "form_var = {$_SESSION['session_var']}<br>\n";
echo "form_var = ".$_SESSION['session_var']."<br>\n";
echo "form_var = $_SESSION[session_var]<br>\n";
[url]http://www.php.net/manual/en/language.types.string.php#language.types.string.sy ntax.double[/url]>Parse error: parse 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.array.php#language.types.array.foo-bar[/url]
(see fourth code example section)
--
Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
Andy Hassall Guest



Reply With Quote

