?
Solved

How to avoid checking for isset?

Posted on 2015-02-19
4
Medium Priority
?
138 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 12

Assisted Solution

by:Nathan Riley
Nathan Riley earned 1000 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 1000 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 84

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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 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