?
Solved

Undefined variable problem

Posted on 2009-05-16
2
Medium Priority
?
224 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:
climbgunks 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

777 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