473,785 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function "isset()" needed in 4.3.5 but not 4.3.0

Hello all,

We are currently changing our web server and, in the process, updating PHP
version from 4.3.0 to 4.3.5. The problem we've got is that our PHP
applications generate errors saying that some of the variables are
Undefined.

I didn't use "if(isset($myVa r))" to validate if a variable has been passed
from a HTML form but instead "if($myVar) ".

Is there a way to make it work without changing the code?

TIA

Yannick

Jul 17 '05 #1
8 1872
On Mon, 05 Apr 2004 10:01:43 -0400, Yannick Turgeon wrote:
Hello all,

We are currently changing our web server and, in the process, updating PHP
version from 4.3.0 to 4.3.5. The problem we've got is that our PHP
applications generate errors saying that some of the variables are
Undefined.

I didn't use "if(isset($myVa r))" to validate if a variable has been passed
from a HTML form but instead "if($myVar) ".

Is there a way to make it work without changing the code?

TIA

Yannick

Interesting.. is $myVar a bool value? If not.. then why do you assume
something is "wrong"? This would appear to be perfectly reasonable.

isset() checks for definition not for data type.

if ($foo) is a boolean check not a def / undef check.

Seriously... the code needs rewriting.. this is seriously flawed if mu
assumptions are correct.. and unfortunately, something all too easily done
in PHP. Maybe they're slowly getting around to making things more strict
and "standard". . which is IMO, a good thing(tm).

Just my £0.02 worth =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2
Thanks Ian for your reply,

I finally found the answer. Yes, I realise this way of testing if variable
has been passed or not from a form is very poor practice. Why I didn't get
any error on the old server was because the parameter "error_reportin g" was
set to exclude "Notices". I did the same on the new server because it would
be too long for the moment to change all the code. It worked.

Yannick

"Ian.H" <ia*@WINDOZEdig iserv.net> wrote in message
news:pa******** *************** *****@bubbleboy .digiserv.net.. .
On Mon, 05 Apr 2004 10:01:43 -0400, Yannick Turgeon wrote:
Hello all,

We are currently changing our web server and, in the process, updating PHP version from 4.3.0 to 4.3.5. The problem we've got is that our PHP
applications generate errors saying that some of the variables are
Undefined.

I didn't use "if(isset($myVa r))" to validate if a variable has been passed from a HTML form but instead "if($myVar) ".

Is there a way to make it work without changing the code?

TIA

Yannick

Interesting.. is $myVar a bool value? If not.. then why do you assume
something is "wrong"? This would appear to be perfectly reasonable.

isset() checks for definition not for data type.

if ($foo) is a boolean check not a def / undef check.

Seriously... the code needs rewriting.. this is seriously flawed if mu
assumptions are correct.. and unfortunately, something all too easily done
in PHP. Maybe they're slowly getting around to making things more strict
and "standard". . which is IMO, a good thing(tm).

Just my £0.02 worth =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #3
[ Posting rearranged into proper Usenet order ]

"Ian.H" <ia*@WINDOZEdig iserv.net> wrote in message
news:pa******** *************** *****@bubbleboy .digiserv.net.. .
On Mon, 05 Apr 2004 10:01:43 -0400, Yannick Turgeon wrote:

[ snip ]
> I didn't use "if(isset($myVa r))" to validate if a variable has been passed > from a HTML form but instead "if($myVar) ".
>
> Is there a way to make it work without changing the code?


[ snip ]

if ($foo) is a boolean check not a def / undef check.

Seriously... the code needs rewriting.. this is seriously flawed if mu
assumptions are correct.. and unfortunately, something all too easily done
in PHP. Maybe they're slowly getting around to making things more strict
and "standard". . which is IMO, a good thing(tm).


On Mon, 05 Apr 2004 11:06:21 -0400, Yannick Turgeon wrote:
Thanks Ian for your reply,

I finally found the answer. Yes, I realise this way of testing if variable
has been passed or not from a form is very poor practice. Why I didn't get
any error on the old server was because the parameter "error_reportin g" was
set to exclude "Notices". I did the same on the new server because it would
be too long for the moment to change all the code. It worked.

No probs Yannick.. glad you found an answer anyway.. but it's also good to
see that you do recognise the "problem" (some people just don't care.. "we
got it to work.. so up yours!" kind of attitude).

I have had similar issues with my own code in the past with some things
(probably most remembered was the register_global s change over for some of
my old scripts). I implemented some hacks to get around the problem until
I had some spare time to rewrite the code _properly_. If a job's worth
doing, it's worth doing right as they say.. but I also appreciate
"immediatel y" isn't often a possible reality =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #4
I noticed that Message-ID:
<pa************ *************** *@bubbleboy.dig iserv.net> from Ian.H
contained the following:
I have had similar issues with my own code in the past with some things
(probably most remembered was the register_global s change over for some of
my old scripts).


It doesn't help when bad habits are shown in tutorials. Although my
server (out of my control) has register globals set to on I always use
$_POST, $_GET etc. I resented having to type extra code at first but
now I'm used to it I find it easier to see where my variables are coming
from.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5
On Mon, 05 Apr 2004 18:11:38 +0100, Geoff Berrow wrote:
I noticed that Message-ID:
<pa************ *************** *@bubbleboy.dig iserv.net> from Ian.H
contained the following:
I have had similar issues with my own code in the past with some things
(probably most remembered was the register_global s change over for some of
my old scripts).


It doesn't help when bad habits are shown in tutorials. Although my
server (out of my control) has register globals set to on I always use
$_POST, $_GET etc. I resented having to type extra code at first but
now I'm used to it I find it easier to see where my variables are coming
from.

Most definitely Geoff.. like you, it comes as "second nature" now
(although my servers are configured with globals off).

That's the other popular explanation / reason for using them (besides the
obvious security).. $_POST['foo'] is a _lot_ more descriptive than $foo =)

I used a kind of securish hack to get around it.. by adding:
$foo = $_GET['foo'];
$bar = $_POST['bar'];
etc etc as the first few lines in the script(s). This still kept the
validation then on where they were coming from. Not the best situation for
debugging.. but the scripts worked.. so this wasn't so important at this
time (not like during development).

As time went on I replaced all of these (actually ended up taking the
application down and replaced with phpBB (was a forum)) because I didn't
have the time to create the next phpBB / vBulletin and the features were
lacking somewhat (administration tasks too longer to do just with phpMA..
les automation).

It's an ever growing learning / experience curve.. by the time I get to 10
years of PHP coding.. I'd still lay a rather large £sum on the table and
say I'd still have lots to learn... but that's also half the fun =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #6
"Yannick Turgeon" <no****@nowhere .com> wrote in message
news:nF******** ***********@new s20.bellglobal. com...
We are currently changing our web server and, in the process, updating PHP
version from 4.3.0 to 4.3.5. The problem we've got is that our PHP
applications generate errors saying that some of the variables are
Undefined.

I didn't use "if(isset($myVa r))" to validate if a variable has been passed
from a HTML form but instead "if($myVar) ".

Is there a way to make it work without changing the code?


Just change error_reporting in php.ini to something like E_ALL &~ E_NOTICE.
Jul 17 '05 #7
"Geoff Berrow" <bl******@ckdog .co.uk> wrote in message
news:pi******** *************** *********@4ax.c om...
It doesn't help when bad habits are shown in tutorials. Although my
server (out of my control) has register globals set to on I always use
$_POST, $_GET etc. I resented having to type extra code at first but
now I'm used to it I find it easier to see where my variables are coming
from.


Now wait a second. When has using register-globals become a bad habit?
Quoting the PHP manual: "the directive itself isn't insecure but rather it's
the misuse of it." My biggest problem with the whole register-globals debate
is that people some how think that it's a more secure way of programming in
PHP. There is, of course, no such thing as more secure--you are either
vulnerable or you're not. And there are plenty of ways to screw up. I don't
know how many times I have seen stuff like

include $_GET['section'] . '.php';

or

if($_SESSION['auth']) {
include("forum. php");
}

or

$ids = implode(',', $_POST['checkboxes]);
mssql_query("SE LECT * FROM books WHERE book_id IN ($ids)");

where the programmer is satistied that he has followed good practice and let
serious issues slip by under his nose.
Jul 17 '05 #8
I noticed that Message-ID: <qu************ ********@comcas t.com> from
Chung Leong contained the following:
It doesn't help when bad habits are shown in tutorials. Although my
server (out of my control) has register globals set to on I always use
$_POST, $_GET etc. I resented having to type extra code at first but
now I'm used to it I find it easier to see where my variables are coming
from.


Now wait a second. When has using register-globals become a bad habit?


Where did I say that? It is a bad habit to write code that is not
portable, as we see here on a daily basis.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #9

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

Similar topics

23
5686
by: ian justice | last post by:
Before i post actual code, as i need a speedyish reply. Can i first ask if anyone knows off the top of their head, if there is a likely obvious cause to the following problem. For the moment i've reduced my form request to a simple text string entry, instead of my desired optional parameters. As i have been stuck with a single unfathomable glitch for over a year. Basically, if i enter queries such as ; "select * from table" "select * from...
32
33069
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at the first time the page is loaded). I tryed this code:
1
4143
by: Westcoast Sheri | last post by:
When "register globals" is set to "on," has anyone noticed if PHP Version 5 affects the usage of "isset" or not? For example, in a webpage form, should the following code: if (!isset($ordernumber)) { $ordernumber = '123456'; } ....be changed to this: if (!isset($orderid) || $orderid==NULL) { $ordernumber = '123456'; }
7
12294
by: deko | last post by:
Why is $_SERVER returning multiple IP Addresses? Actually, I'm not sure if it's $_SERVER -- or which if/else statement -- that's the problem, but what I'm getting as a value for $visip looks like this: 172.16.42.181, 62.138.35.94 Why am I getting more than one IP Address? Which IP is the originating IP Address? Is there a way to get only the originating IP?
1
4196
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens in IE as well as FireFox. This code has been tested on a Win2003 server, IIS6, PHP 5.0.3, mySQL 4.1.8 and it works fine. The problem server is a Win2k server, IIS5, PHP 5.0.4, mySQL 4.1.11.
5
1992
by: juglesh | last post by:
"$string = isset($xyz) ? $xyz : "something else";" Hello, someone gave code like this in another thread. I understand (by inference) what it does, but have not found any documentation on this type of syntax. Any one have links to this shortuct(?) syntax and other types of syntax? thanks
4
2684
by: Marcin Dobrucki | last post by:
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; }
11
2159
by: comp.lang.php | last post by:
function blah($item) { if (!isset($baseDir)) { static $baseDir = ''; $baseDir = $item; print_r("baseDir = $baseDir\n"); } $dirID = opendir($item); while (($fyl = readdir($dirID)) !== false) { if (is_dir("$baseDir/$fyl")) blah($item);
7
1468
by: Big Moxy | last post by:
Would someone be so kind as to tell me what is wrong with this code? (1) This code block indicates the session variable nomex is null. if (is_null($_SESSION)){ echo " is null."; } else { echo " is not null."; }
0
9480
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,...
1
10083
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
9946
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
8968
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
6737
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
5379
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
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.