Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Notice: Undefined variable

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
We just set up PHP on a new server and have been getting the following error on many pages:

Notice: Undefined variable

This led me to believe this was a register_globals issue. I created an .htaccess file and flagged register_globals to be true. I can confirm the local value for register_globals is set to "on" now with phpinfo(). However, the problem still remains.

Are there any other settings I'm missing here? This script worked fine on our old host...
 
It is probably a difference in the error reporting. Notice is not an error and script does not halt on that. Some servers suppress notices. Basically, what that notice is saying that you're calling a variable that is not initialized yet. You can avoid the notice by encompassing the variable in isset() function.

As for register globals, make sure they are off, because that is the recommended way.
 
Thanks. That cleared it up. Yes, we are moving away from using register_globals, but for some of our less important sites from back in the day, it's fine.
 
You can also change your Error Reporting in PHP.ini to this:

error_reporting = E_ALL & ~E_NOTICE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top