Solved

How to avoid checking for isset?

Posted on 2015-02-19
4
126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

738 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