[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Undefined variable problem

Posted on 2009-05-16
2
Medium Priority
?
225 Views
Last Modified: 2012-05-07
yikes, this is a bit of a mess.

I'm moving my sites to a new server.  The new server has php5, (my old one just php4), but I can run sites through php4 via cgi.

On one of the scripts I am trying to run on the new server (using php4 for now), goes like this:

-------
if (!$loc){ //start if
 $time='<FONT COLOR="#223D75" STYLE="font-size: 13px">- time will appear here -</FONT>';}
--------

I'm getting an error like this:
---------
Notice: Undefined variable: loc in /home/mysite/public_html/data/wwc.php on line 5
--------

What do I do about that?  I mean, my whole 'if' test is to see if it has a value, and if it doesn't, do such and such.  

Do I need to write this differently, or change something in php.ini (it worked on my old server), or is there something else?

Thanks,  Chris

ps: the goal is to get all my sites php5 compatible, but I put them on php4 for now just to get them going so I can work on them.  I did try this site on php5 and got lots of errors, so I backed off and just going to try the smaller issues until I get everything moved.

0
Comment
Question by:St_Aug_Beach_Bum
[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
2 Comments
 
LVL 11

Accepted Solution

by:
Todd Mummert earned 2000 total points
ID: 24404570

If it's a new server you're testing this against, it may be a registers_global setting that is different.  Fortunately, if it is there are a number of ways around it, either by modifying your code, or adding an entry to your .htaccess file..

See this article for much more info on this problem:

http://forums.devarticles.com/php-development-48/php-undefined-variable-error-from-form-to-script-5156.html
0
 

Author Closing Comment

by:St_Aug_Beach_Bum
ID: 31582298
Thank you climbgunks,

I didn't get an answer from that page, per se, but it did lead me down the path of investigating .htaccess more closely, and I realized that I had

AddType application/x-httpd-php .php .php4 .php3  .html .htm

in .htaccess, and:

AddHandler php4-script .php .htm .html

in the httpd.conf file (to get the php4 cgi working).

Wondered if that might cause some problem, so I took it out of .htaccess and voila, things are working :)

So thanks for getting me going in the right direction!

Chris
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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 look for a specific file type in a local or remote server directory using PHP.
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…
Suggested Courses

649 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