473,403 Members | 2,354 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,403 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 59755
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.