This line of code make an "Undefined index" error on my PC, however it is
okay on my friend's PC.
Anyone has this experience?
$somevar = $_REQUEST["name"]; 7 12200
"melty" <m@lty.com> wrote in message news:1090294263.937002@hkpu01... This line of code make an "Undefined index" error on my PC, however it is okay on my friend's PC. Anyone has this experience?
$somevar = $_REQUEST["name"];
Try accessing the page with a query string of "?name=foo" or sending a
$_POST variable called "name"...
kingofkolt wrote: "melty" <m@lty.com> wrote in message news:1090294263.937002@hkpu01...
This line of code make an "Undefined index" error on my PC, however it is okay on my friend's PC. Anyone has this experience?
$somevar = $_REQUEST["name"];
Try accessing the page with a query string of "?name=foo" or sending a $_POST variable called "name"...
A high level of error reporting will also cause PHP to print those
messages/warnings.
In php.ini;
error_reporting = E_ALL & ~E_NOTICE
should suffice.
>This line of code make an "Undefined index" error on my PC, however it is okay on my friend's PC. Anyone has this experience?
$somevar = $_REQUEST["name"];
My approach to this is: always use isset() on any variable you
aren't absolutely sure is set before trying to use its value. You
can NEVER be sure that a particular variable in $_GET, $_POST,
$_REQUEST, $_COOKIE, $_SERVER, or $_SESSION is set at the start of
execution of your page. Consider any "undefined index" or "undefined
variable" message to be a bug in your code.
Also, use error_reporting(E_ALL) to make sure that if you use
an uninitialized value, it gets reported.
Gordon L. Burditt
"Gordon Burditt37" wrote: This line of code make an "Undefined index" error on my PC, however it isokay on my friend’s PC. Anyone has this experience?
$somevar = $_REQUEST["name"];
My approach to this is: always use isset() on any variable you aren’t absolutely sure is set before trying to use its value. You can NEVER be sure that a particular variable in $_GET, $_POST, $_REQUEST, $_COOKIE, $_SERVER, or $_SESSION is set at the start of execution of your page. Consider any "undefined index" or
"undefined variable" message to be a bug in your code.
Also, use error_reporting(E_ALL) to make sure that if you use an uninitialized value, it gets reported.
Gordon L. Burditt</font>
I second Gordon’s comment. Tight error reporting ensures that you
catch some very pesky bugs- more work, more reward.
If undefined is a valid value for any variable--in other works you
don’t want to get any warnings, then use this function around your
variable.
$somevar = nullit($_REQUEST["name"]);
Function nullit(&$varin) { //must pass by reference, so there is no
explicit copying of var data
//if undefined variable, then returns ’’ without doing an error,
otherwise just returns the var.
//this is done so we don’t get warning
if (isset($varin)) {
return ($varin);
}
else {
return (’’);
}
}
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-_REQUEST...ict131132.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=437578
"Gordon Burditt37" wrote: This line of code make an "Undefined index" error on my PC, however it isokay on my friend’s PC. Anyone has this experience?
$somevar = $_REQUEST["name"];
My approach to this is: always use isset() on any variable you aren’t absolutely sure is set before trying to use its value. You can NEVER be sure that a particular variable in $_GET, $_POST, $_REQUEST, $_COOKIE, $_SERVER, or $_SESSION is set at the start of execution of your page. Consider any "undefined index" or
"undefined variable" message to be a bug in your code.
Also, use error_reporting(E_ALL) to make sure that if you use an uninitialized value, it gets reported.
Gordon L. Burditt</font>
I second Gordon’s comment. Tight error reporting ensures that you
catch some very pesky bugs- more work, more reward.
If undefined is a valid value for any variable--in other works you
don’t want to get any warnings, then use this function around your
variable.
$somevar = nullit($_REQUEST["name"]);
Function nullit(&$varin) { //must pass by reference, so there is no
explicit copying of var data
//if undefined variable, then returns ’’ without doing an error,
otherwise just returns the var.
//this is done so we don’t get warning
if (isset($varin)) {
return ($varin);
}
else {
return (’’);
}
}
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-_REQUEST...ict131132.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=437578
"Gordon Burditt37" wrote: This line of code make an "Undefined index" error on my PC, however it isokay on my friend’s PC. Anyone has this experience?
$somevar = $_REQUEST["name"];
My approach to this is: always use isset() on any variable you aren’t absolutely sure is set before trying to use its value. You can NEVER be sure that a particular variable in $_GET, $_POST, $_REQUEST, $_COOKIE, $_SERVER, or $_SESSION is set at the start of execution of your page. Consider any "undefined index" or
"undefined variable" message to be a bug in your code.
Also, use error_reporting(E_ALL) to make sure that if you use an uninitialized value, it gets reported.
Gordon L. Burditt</font>
I second Gordon’s comment. Tight error reporting ensures that you
catch some very pesky bugs- more work, more reward.
If undefined is a valid value for any variable--in other works you
don’t want to get any warnings, then use this function around your
variable.
$somevar = nullit($_REQUEST["name"]);
Function nullit(&$varin) { //must pass by reference, so there is no
explicit copying of var data
//if undefined variable, then returns ’’ without doing an error,
otherwise just returns the var.
//this is done so we don’t get warning
if (isset($varin)) {
return ($varin);
}
else {
return (’’);
}
}
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-_REQUEST...ict131132.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=437578
.oO(John Unleaded Smith) A high level of error reporting will also cause PHP to print those messages/warnings.
In php.ini;
error_reporting = E_ALL & ~E_NOTICE
should suffice.
Not on a development system. Better fix the problem instead of turning
off notices.
$somevar = isset($_REQUEST['name']) ? $_REQUEST['name'] : '';
Even if it's "only" a notice, it's possible that the code does not
exactly do what you expect it to do. Fixing notices prevents some hard
to find bugs.
Micha This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: toufik toufik |
last post by:
Hi,
I've a variable that can come with the GET and POST method, So I use
$_REQUEST to get it
When I use a simple href
href="myFile.php?myVar=value"
I have myVAr in the $GET and $_REQUEST arrays....
|
by: Sandro Dentella |
last post by:
I have some scripts that used to work under webmin under
Debian(woody). Under Debian Sarge php passed from 4.1.2 to 4.3.4 and I'm
experimenting several problems.
Among the others, array...
|
by: Sean |
last post by:
Hello,
The isset($_REQUEST) works okay on other servers but not on
mine. The way the application works is the links are provided as:
http://url.com/cc.php?page=currencies&new
And then in...
|
by: Geoff Soper |
last post by:
I'm working on an authentication system in which it's possible that a user
might be requested to log-in as a result of submitting a form if the
inactivity timeout is exceeded. In order that they...
|
by: Geoff Winkless |
last post by:
Hi
My knowledge of php is regrettably poor but I need to call a third-party
php script from within a bash cgi script (don't ask why, it's a long
story). Now normally (with eg perl-cgi) to do...
|
by: jmark |
last post by:
I have seen some code like
$value = strval($REQUEST);
I would like to know what is the use of strval here since $_REQUEST
values are strings?
|
by: Fred!head |
last post by:
Hi,
Probably this is a newbie question so I appreciate you bearing with
me.
I've got an application where users can create forms with name= values
they define. I'd like to write a script that...
|
by: sathyashrayan |
last post by:
Dear Group,
Please look at the following demo link.
http://www.itsravi.com/demo/new_pms/admin/addproject.php
|
by: hassnajib |
last post by:
I am having problem retrieving $_REQUEST array key/value i submintted using post method. here is the simple form I am posting:
<html>
<head>
</head>
<body>
<form...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |