/    Sign up×
Community /Pin to ProfileBookmark

Randomly no script execution

I have a simple PHP script, which uses sessions.
Most times it works, but sometimes it will not be executed (no errors, just no execution).
Without using sessions it works everytime.

What can I do?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@CompGeek01Jul 08.2005 — Post code samples so we can make sure you're using them properly? Without anything to go on... *shrug*.
Copy linkTweet thisAlerts:
@langhaarauthorJul 08.2005 — I don't think, that the code will be helpful. But here you go:

<i>
</i>&lt;?php
ob_start();
session_start();

$_SESSION['Person']=$_POST['Person'];

if ($_POST['zurueck']=="zurueck")
{
include("p2b.html");
exit;
}

if ($_POST['weiter']=="weiter")
{
include("p4b.html");
exit;
}
?&gt;
Copy linkTweet thisAlerts:
@ScleppelJul 08.2005 — Maybe you could try isset() :
[code=php]
if (isset($_POST['zurueck']))
// instead of
if ($_POST['zurueck']=="zurueck")

// and

if (isset($_POST['weiter']))
// instead of
if ($_POST['weiter']=="weiter")
[/code]

because then the actual value of the POST variable doesn't matter.

EDIT: You should also put else{} at the end for when people don't post anything to the script.
[code=php]
else{
echo 'Error: You have to POST from a form to this page';
}
[/code]
Copy linkTweet thisAlerts:
@langhaarauthorJul 08.2005 — Sorry, there's some misunderstandung.

The script works well but sometimes it will not be executed. That is the reason, why I don't think, it has to do direrctly with the script. Maybe some caching prevents it from being executed?

But thanks for the isset advice. This looks better than my solution :-)

(An else branch is not needed because the script can only be entered by the two buttons)
Copy linkTweet thisAlerts:
@ScleppelJul 08.2005 — What do you mean by no executing? A blank output? A blank output from your script would just mean $_POST['zurueck'] didn't equal "zurueck" and $_POST['weiter'] didn't equal "weiter". If you add an else it would show the error if this is the case. And i can get to you script without clicking the buttons, just a quick veiw source, i'm not saying i would, but someone might and not get what they're expecting or something.
Copy linkTweet thisAlerts:
@langhaarauthorJul 08.2005 — Not a blank output, no output at all (the HTML page with the form remains).

I added an echo in the script like this:

<i>
</i>&lt;?php
ob_start();
session_start();

$_SESSION['Person']=$_POST['Person'];
echo ("EXECUTION");
.
.
.
?&gt;


and everytimes the script isn't working there is also no output.

Therefore I guess, the script is not executed at all.

Without the using sessions it works everytime.
×

Success!

Help @langhaar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...