Solved

How to avoid checking for isset?

Posted on 2015-02-19
4
117 Views
Last Modified: 2015-02-19
Our website was running just fine on a shared web hosting server until yesterday, when we suddenly started receiving the following message on every page:

"The page cannot be displayed because an internal server error has occurred."

We tracked it down to the PHP code failing to check first to see if a SESSION var had been set, by using the isset() function, before we referenced the SESSION var.

The site runs fine on our test server running PHP 5.3.27, but the live web host just upgraded to 5.3.28 and now our site is down since it is full of references to SESSION vars without first checking them via the isset() function.

Question: Is there is a quick and dirty setting we can use on the live site to quickly get our site back up and running again while we go through the tons of code to get all the isset() calls in place?

Thanks experts!
0
Comment
Question by:rascal
4 Comments
 
LVL 11

Assisted Solution

by:N R
N R earned 250 total points
ID: 40619517
What are the sessions handling?

It's failing because sessions are not set?  Depending on what the sessions are responsible for a quick and dirty way to get it back up would be to set the sessions to anything in the header such as the below until you get all of your code fixed.

$_SESSION['sessionname'] = 0;

Open in new window

0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 250 total points
ID: 40619520
I think undefined variables are flagged as NOTICES, so you could turn error reporting off for just those:

error_reporting( error_reporting() & ~E_NOTICE )

You'll probably find that your previous server had register_globals turned on and your new one has it turned off - so you could try turning it back on again.

Both of these suggestions should only be seen as temporary, as they could both have disastrous side effects and compromise your server!!
0
 
LVL 1

Author Closing Comment

by:rascal
ID: 40619630
Thanks experts!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40619709
Your host could have a different error level set than your test server.  In general, you should use 'isset' for external variables like $_GET, $_POST, and $_REQUEST and whenever there may be a question whether $_SESSION variables are set.  Every form action page I write starts out with a check for 'isset' for every single form variable that could be there.  Especially important to use it to set a default value for things like checkboxes that are not submitted if they are not checked.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now