Okay, I'm trying to write a new asset management database for the school. I am using a WAMP environment on Windows 2003 R2 in a M$ Virtual Server VM.
if ($_SESSION['status'] == 8)
echo "never gets this far Grrrr.";
echo "<form action=\"module/thispage.php\" method=\"post\"><tr>";
echo "<td>form stuff</td><td>form stuff</td>";
echo "<td><input type=\"submit\" value=\"ADD\" />";
echo "<tr><td>non form stuff</td><td>non form stuff</td><td> </td></tr>";
$_SESSION['status'] = 8;
Everything has been going swimmingly until I hit upon this problem I just can't see the answer to. The above is a heavily edited version of the script causing me problems.
On the first pass:
'test', the table and form contents, and '8' are displayed on the screen.
When you click on the 'ADD' button to initiate the second pass I get a:
HTTP 500 error.
Now, the address in the form action is correct. If I change it to another page in the same folder the 'ADD' button works. But when it is asked to reload this page, it doesn't!
I have used the same basic code on around half dozen pages without problem.
The only other thing of significance is that I am posting around 10 variables from the form this time. That said I have another script that can dynamically post 10's (100's) of variables from it's form and that works without error.
Anyone got any pointers, something I should be looking at/for to resolve this strange problem?
Just tried your code here and it works apart from needing a couple of fixes.
removed the $ from line 2
added ; to line 3
changed form action path to my test page
Have you looked at the apache logs to see if any info is in there?
Sorry, couple of simple typos dumbing down the page to the bit that is wrong.
I've used the same code loads of times without problems. Anyone got any ideas what might be causing a HTTP500 error? I've been staring at this for far too long. Grrr.
what browser are you using?
Have you tried IE with friendly errors turned off?
I am using IE8. Didn't know about friendly errors. Turned off and got an interesting result. the "test" before the if statement is displayed. But nothing is displayed from either clause in the if statement.
I'm going to check the session variable and see if I have a problem joining the session.
first pass result in "test 9" followed by the table/form followed by "8". correct :)
echo "test"." ".$_SESSION['status']
second pass results in "test 0".
so I'm loosing my connection to the session between iterations! Question is, how do I fix that? I thought 'session_start();' at the start of every page took care of that for me?
have a look in the folder where sessions are stored (defined by session.save_path in php.ini) and see if session files are being created. If not you may have a permissions problem.
Check your PHP.INI file - you could try turning on Register Globals, often the cause of a problem with a lot of scripts where you're expecting passed variables and suddenly it doesn't work.
remember to do a strip slashes strip tags on your input for a bit of security on your code!
you could try a reassign of your session variables if you've got an include for starting sessions... $_SESSION['myvar'] = $myvar;
one I usually use also is a cache control:
this helps retain information page to page if input by users is buggered ;)
Here's the thing. I've got half a dozen pages with the same code. The rest work fine!?! The session is being created and variables successfully passed among all the other pages. When the it comes to this page. The first iteration and the session and variables are fine. The second and (same code) it's not !?!
If this was the first page of a new project I'd agree - session not being created - but when you're this far through the coding process. I have almost 30 php scripts so far making up this project. Almost all of them use session_start(); and no other page - regardless of which folder it is stored in or how meny times it is called - is causing any problems with session variable passing.
What could make WAMP/IE lose the session between pushing the 'ADD' button and reloading the php script?
have you looked at the session id to check it is the same when the page reloads?
if you are getting a different id on reload then the session vars will be lost
this can happen if cookies are blocked for some reason.
@tsky: no joy on the register globals (which was turned off - now on), also adding cache control to that page is not effective. Re-assigning session variable is a non starter. At this point they contain data I need to extract. I also can't understand why the session variables are correct during the first run of the script - when the else block is run - but not during the second run of the script. It's the same script !?!
This is getting stranger. May try with a different web browser, Safari on me Mac, in a moment. But, I can't find the cookie that stores the SID for the session? I can find other cookies but not this one! Which is strange as all other pages are working and would be relying on this information.
Originally Posted by cadjs
after the session_start()
Is it losing connection? Surely if the connection was lost $_SERVER['status'] wouldn't be initialised? It seems the value is there but set to 0.
Originally Posted by tmcd35
What about looking at the web server logs. Your earlier 500 errors should be there.
Thanks @cadjs, should have thought of that!
The session id is the same value! Trying a
In the first half of the if statement to see what results I get there.:confused:
echo "<br>".$_SESSION['temp']." ";