473,890 Members | 1,164 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
22 6744
Hell off topic with them.. but you might want to check
htmlspecialchar s() on that script there.. sql injections visible at
first glance..

but anyways, you were on the right track with isset, i suggest just
making a simple function?
that is, if you are trying to assign a post/get variable to a php
variable... you could do somthign like this..

function setvar($var){
if(isset($_POST[$var])){
return $_POST[$var];
}
if(isset($_GET[$var])){
return $_GET[$var];
}
return "";
}

then just use
$p = setvar("p");
and p will be either the get, post, or "".

but the method you are using is doing one isset, with my local apache
it brings up errors like you have when i have unassigned variables, so
the easiest and safest thing to do is set them to null, then use the
isset..

$p = "";
if(isset($_GET['p'])) $p = $_GET['p'];

that will cause p to only be set with the get value if there is one..
(duh)

Jul 17 '05 #21

"Daniel Tryba" <sp**@tryba.inv alid> wrote in message
news:41******** **************@ news.xs4all.nl. ..
| In comp.lang.php steve <a@b.com> wrote:
| > | Quite possibly a bug in PHP 5. Sounds like one that causes the server
to
| > | sigfault, since PHP didn't even manage to flush the output buffer.
| >
| > i was fearful of that and, all indications are that it is so since
reverting
| > to php 4.3 and running the same code gives no errors and produces
exactly
| > the expected results.
|
| At the same level of error_reporting ?

hard to say "same" here, as i tried all different combinations of error
reporting on php 5. it simply stopped spewing output when it hit an
uninitialized variable. with php 4.3, i have e_all & ~ e_notice...whic h is
the default i believe.

i don't know if it made a difference in installation, but i did not
uninstall php 4.3 prior to the php 5 install...which did not require a
re-boot once complete (and i hadn't rebooted manually either). when the
problem showed itself and i could not resolve it, i uninstalled php 4.3. the
problem persisted. i uninstalled php 5 (*did* require a reboot) then
reinstalled php 4.3. may just have had a dll from 4.3 in memory until the
reboot...or something like that.

when i retry php 5, i'll take off php 4.3, reboot, then install 5 and see
what happens with the app then.

thanks for everyone's help.
Jul 17 '05 #22
| Hell off topic with them.. but you might want to check
| htmlspecialchar s() on that script there.. sql injections visible at
| first glance..

yeah, there are a couple of things i'll go back and fix after i get the bulk
of the script written...i need to add data-prep (validation, error
reporting, etc.) which will be responsible for prep-ing it for use with sql
among other things.

mainly just working out connectivity, basic sql, and page layout(s) now.

| but anyways, you were on the right track with isset, i suggest just
| making a simple function?

i actually changed it to use $_request (which uses the php.ini settings for
variable assignment order):

$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;

this accomplishes the same thing as the example you posted and always sets
the var.

thanks for your thoughts and suggestions!

cheers,

steve
Jul 17 '05 #23

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
2591
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
6565
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
5641
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
9978
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
9820
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
11227
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
10812
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...
0
10462
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
9630
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5848
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
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.