473,811 Members | 2,788 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 6731
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
2586
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
6556
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
5612
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
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10663
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
10401
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
10416
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,...
1
7676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
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.