473,480 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 59758
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
8255
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
6112
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
4127
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
1816
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
3434
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
7949
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
7558
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
7051
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
6915
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
7097
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...
1
6750
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
6993
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
5353
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,...
0
4493
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.