473,692 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php 5 and uninitialized variables

i've setup a include page that's responsible for building the basic layout
of my web pages (header, menus, etc.). each page includes this
"sysheader.php" .

the first page i've built with this header is having odd results. its job is
to add users to the system. the variables i expect to be there are: id,
userName, password...stuf f like that. after the require_once
"sysheader.php" , i've put an "exit;" statement. the header shows perfectly.
if i try and access or set one of the expected variables, only part of the
header shows...crappin g out around the time it is building the company
logo - so that i see "<img src="http://www" and nothing else.

i've tried to set my own variable order and initialze the variables myself
like this:

$id = (isset($_POST['id']) ? $_POST['id'] : $_GET['id']);

but that doesn't work either. i've been running similarly constructed pages
successfully under php < 5...what am i missing now that i'm moving to php 5?

tia,

steve

Jul 17 '05 #1
22 6715
steve wrote:
i've setup a include page that's responsible for building the basic
layout of my web pages (header, menus, etc.). each page includes this
"sysheader.php" .

the first page i've built with this header is having odd results. its
job is to add users to the system. the variables i expect to be there
are: id, userName, password...stuf f like that. after the require_once
"sysheader.php" , i've put an "exit;" statement. the header shows
perfectly. if i try and access or set one of the expected variables,
only part of the header shows...crappin g out around the time it is
building the company logo - so that i see "<img src="http://www" and
nothing else.

i've tried to set my own variable order and initialze the variables
myself like this:

$id = (isset($_POST['id']) ? $_POST['id'] : $_GET['id']);


REQUEST[ 'id' ] if my memory serves me correctly has either POST or GET
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
Jul 17 '05 #2
steve wrote:
i've tried to set my own variable order and initialze the variables
myself like this:

$id = (isset($_POST['id']) ? $_POST['id'] : $_GET['id']);

but that doesn't work either. i've been running similarly constructed
pages successfully under php < 5...what am i missing now that i'm
moving to php 5?


You could also do something like:

$id = @$_REQUEST['id'];

This will catch the id when it's posted or passed as a GET parameter or
create an empty variable without warnings, whichever is appropriate.

Anyways, I'm almost certain that your code relies on register_global s being
enabled, while with PHP 5 it's disabled by default as it should.

Enable the register_global s directive in your php.ini file and check if the
code works. When it does, you will have to convert all code that relies on
register_global s, which also includes the session system.
JW

Jul 17 '05 #3
| REQUEST[ 'id' ] if my memory serves me correctly has either POST or GET

thank for the info...didn't fix the problem though. any other ideas on how
to handle expected, yet uninitialized, variables? can i change something in
the php.ini file?
Jul 17 '05 #4
steve wrote:
thank for the info...didn't fix the problem though. any other ideas
on how to handle expected, yet uninitialized, variables? can i change
something in the php.ini file?


Use isset() to check if they exist or prepend the @ sign to surpress error
messages. Don't mess with the error_reporting settings, because surpressing
notices and warnings at this level will only cause errors to be harder to
find.
JW

Jul 17 '05 #5
| You could also do something like:
|
| $id = @$_REQUEST['id'];
|
| This will catch the id when it's posted or passed as a GET parameter or
| create an empty variable without warnings, whichever is appropriate.
|
| Anyways, I'm almost certain that your code relies on register_global s
being
| enabled, while with PHP 5 it's disabled by default as it should.
|
| Enable the register_global s directive in your php.ini file and check if
the
| code works. When it does, you will have to convert all code that relies on
| register_global s, which also includes the session system.

thanks for the input...it doesn't take care of the problem though. i have
register_global s=Off and did not have it set otherwise in previous versions
of php. enabling that setting in php 5 sends it merrily running on and on
until i have to kill the process manually.

i do get output but the buffer only spews until it hits the line of code
where a variable is utilized (set/get) but not initialized.

any further input is greatly apprecieated.
Jul 17 '05 #6
| Use isset() to check if they exist or prepend the @ sign to surpress error
| messages. Don't mess with the error_reporting settings, because
surpressing
| notices and warnings at this level will only cause errors to be harder to
| find.

i have tried using isset() and the @ sign previously...bu t to no avail.
should i just turn on logging and see what php reports?
Jul 17 '05 #7
steve wrote:
thanks for the input...it doesn't take care of the problem though. i
have register_global s=Off and did not have it set otherwise in
previous versions of php. enabling that setting in php 5 sends it
merrily running on and on until i have to kill the process manually.

i do get output but the buffer only spews until it hits the line of
code where a variable is utilized (set/get) but not initialized.


Okay, then it's time to try changing the error_reporting level. This will
only be a test, ensure to restore it to its original level when done
testing.

Go to the ini file and check that the error_reporting directive looks as
follows:

error_reporting = E_ALL & ~E_NOTICE

Then check if the scripts work now.
JW

Jul 17 '05 #8
steve wrote:
i have tried using isset() and the @ sign previously...bu t to no
avail. should i just turn on logging and see what php reports?


Ah, so you don't see any error output, but the script just stops? Yes, then
you definitely need to enable logging.

You can enable the display_errors directive in the ini file for easy
debugging.
JW

Jul 17 '05 #9
| Ah, so you don't see any error output, but the script just stops? Yes,
then
| you definitely need to enable logging.
|
| You can enable the display_errors directive in the ini file for easy
| debugging.

right...but this is also part of my quandry. display_errors is set to On
*and* i don't see any errors in my browser prior to the script crapping out.
Jul 17 '05 #10

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

Similar topics

4
360
by: Jakob Bengtsson | last post by:
Hi I'm trying to show a form as a dialog (using the .ShowDialog() method). After showing the dialog, I want to dispose of the form I use this design (simplified to clarify the point) MyDialog dlg tr dlg = new MyDialog()
12
2573
by: jyu.james | last post by:
I'm trying to detect reads of uninitialized global variables (that are declared in one file, and used in another as an extern). I know that ANSI C initializes all global variables to 0, however, I do not want to rely on this for initialization. Instead, I want to explicity initialize all variables myself. I've looked at tools like Compuware BoundsChecker, which does an amazing job in detecting uninitialized variables, but doesn't...
23
6540
by: Tim Anderson | last post by:
Is this expected behavior? Winform with button and listbox: Dim i As Integer For i = 0 To 50 Dim s As String If i = 1 Then s = "Only once?" End If
148
5516
by: onkar | last post by:
Given the following code & variable i . int main(int argc,char **argv){ int i; printf("%d\n",i); return 0; } here i is allocated from bss or stack ?
0
8611
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9090
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8969
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8812
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5822
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2242
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1962
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.