Solved

Undefined variable problem

Posted on 2009-05-16
2
216 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
2 Comments
 
LVL 11

Accepted Solution

by:
climbgunks earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
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…
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.

757 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

19 Experts available now in Live!

Get 1:1 Help Now