Solved

How to avoid checking for isset?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TCPDF HTML Table of Contents how can I create leading dots 7 39
Problem with Simple PHP/mySQL Query 3 51
How to use md5 hashing 3 26
PHP warning 4 30
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

911 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

17 Experts available now in Live!

Get 1:1 Help Now