473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP saying I have an undefined variable?

Hi,

I get the following error:
Notice: Undefined variable: end_while in C:\Program
Files\Apache\Apache2\htdocs\csp\inc\xmlmenu.php on line 102
This is a script that works on the server at work but it has difficulty
with me running on my home desktop. The variable, $end_while, is just a
basic variable. Is this a configuration problem where you can allow
undefined variables? Ive never had to define variables in the past.

Cheers

Burnsy

Jul 17 '05 #1
3 59754
bi******@yahoo.co.uk wrote:
Notice: Undefined variable: end_while in C:\Program
Files\Apache\Apache2\htdocs\csp\inc\xmlmenu.php on line 102
This is a script that works on the server at work but it has difficulty
with me running on my home desktop. The variable, $end_while, is just a
basic variable. Is this a configuration problem where you can allow
undefined variables? Ive never had to define variables in the past.


See: http://php.net/error_reporting

Example 1 shows how to turn it off. _BUT_ you shouldn't do that, fix the
code instead.

Jul 17 '05 #2
Note that this is not an error but a notice - there's a difference. Errors
will stop execution of your script, while warnings and notices are there to
inform you of possible faulty code. Depending on your error_reporting
setting in php.ini, you may or may not see warnings and notices. Your script
has an undefined variable on your server but your server is just not telling
you, because error_reporting is set to off or warn (not all).

It is likely that you are using $end_while in a conditional statement before
you have defined it, leading to the notice. You should set it to a default
value at the beginning of your script, or before you use it.

ECRIA
http://www.ecria.com
Jul 17 '05 #3
If you dont want to define the variable first - you can always use a
conditional to act if it doesnt exist:
if(!isset($varname))
{
do something
}
Or to supress the notices you can set the PHP error level reporting at
runtime using:
error_reporting(E_ALL ^ E_NOTICE);
That is; if you dont have access to your PHP.ini!

Regards
- FrobinRobin

ECRIA Public Mail Buffer wrote:
Note that this is not an error but a notice - there's a difference. Errors
will stop execution of your script, while warnings and notices are there to
inform you of possible faulty code. Depending on your error_reporting
setting in php.ini, you may or may not see warnings and notices. Your script
has an undefined variable on your server but your server is just not telling
you, because error_reporting is set to off or warn (not all).

It is likely that you are using $end_while in a conditional statement before
you have defined it, leading to the notice. You should set it to a default
value at the beginning of your script, or before you use it.

ECRIA
http://www.ecria.com


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dan Finn | last post by:
OpenBSD 3.2 Apache 1.3.26 PHP 4.3.4 PHP-Nuke 6.9 getting these in the apache error log: Sun Nov 16 20:20:16 2003] PHP Notice: Undefined variable: HTTP_USER_AGENT in...
3
by: Jason | last post by:
hello, i am new to PHP, so go easy. I am using the examples in the book: PHP: Your Visual Blueprint For Creating Open Source, Server Side Content In the section where they talk about...
4
by: Chris Beall | last post by:
If you want your code to be bulletproof, do you have to explicitly check for the existence of any possibly-undefined variable? Example: window.outerHeight is defined by some browsers, but not...
6
by: Jeremy Felt | last post by:
Newbie here. I'm sure I'm missing something EXTREMELY simple, but an hour of searching has led to nothing. I'm playing around with ajax and trying to pass a variable to a function. If I do:...
2
by: Bob Bruyn | last post by:
I've recently installed Apache 2 and php 5.2 on my WIndows XP machine. Everything is up and running. I'm passing some vars via the URL. It works fine online:...
10
blyxx86
by: blyxx86 | last post by:
Good Morning, I have a set of variables being passed to a form via CodeIgniter's MVC setup, however I am trying to keep from duplicating the form elements if at all possible. However, I am...
1
by: bob johnson | last post by:
Notice: Undefined variable: db_host in C:\wamp\www\cbmall\index.php on line 7 Notice: Undefined variable: db_user in C:\wamp\www\cbmall\index.php on line 7 Notice: Undefined variable: db_pass...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.