Solved

How to avoid checking for isset?

Posted on 2015-02-19
4
105 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 42

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 82

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
php mail headers 2 13
PHP Script - Am I missing anything here? 8 39
Apostophes in PHP generated form 6 20
Datepicker in PHP 9 21
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 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

10 Experts available now in Live!

Get 1:1 Help Now