 |
|
 |
|
Next: Session Security
|
| Author |
Message |
External

Since: Jul 20, 2004 Posts: 1
|
(Msg. 1) Posted: Mon Jul 19, 2004 11:54 pm
Post subject: $_REQUEST problem Archived from groups: comp>lang>php (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Apr 07, 2004 Posts: 21
|
(Msg. 2) Posted: Tue Jul 20, 2004 12:54 am
Post subject: Re: $_REQUEST problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"melty" <m.RemoveThis@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"...<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |
External

Since: Jun 28, 2004 Posts: 1
|
(Msg. 3) Posted: Tue Jul 20, 2004 12:54 am
Post subject: Re: $_REQUEST problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
kingofkolt wrote:
> "melty" <m.DeleteThis@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.<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |
External

Since: Jul 20, 2004 Posts: 1
|
(Msg. 4) Posted: Tue Jul 20, 2004 12:54 am
Post subject: Re: $_REQUEST problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
>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<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |

Joined: Jan 06, 2004 Posts: 655
|
(Msg. 5) Posted: Tue Jul 20, 2004 1:02 am
Post subject: Re: $_REQUEST problem [Login to view extended thread Info.]
|
|
|
| Gordon Burditt37 wrote: |
>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</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 ('');
}
} >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |
External

Since: Jun 20, 2004 Posts: 22
|
(Msg. 6) Posted: Tue Jul 20, 2004 1:53 am
Post subject: Re: Re: $_REQUEST problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Gordon Burditt37" wrote:
> >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</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 (’’);
}
}
--
<a style='text-decoration: underline;' href="http://www.dbForumz.com/" target="_blank">http://www.dbForumz.com/</a> This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: <a style='text-decoration: underline;' href="http://www.dbForumz.com/PHP-_REQUEST-problem-ftopict131132.html" target="_blank">http://www.dbForumz.com/PHP-_REQUEST-problem-ftopict131132.html</a>
Visit Topic URL to contact author (reg. req'd). Report abuse: <a style='text-decoration: underline;' href="http://www.dbForumz.com/eform.php?p=437578" target="_blank">http://www.dbForumz.com/eform.php?p=437578</a><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |
External

Since: Jun 20, 2004 Posts: 22
|
(Msg. 7) Posted: Tue Jul 20, 2004 1:53 am
Post subject: Re: Re: $_REQUEST problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
"Gordon Burditt37" wrote:
> >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</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 (’’);
}
}
--
<a style='text-decoration: underline;' href="http://www.dbForumz.com/" target="_blank">http://www.dbForumz.com/</a> This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: <a style='text-decoration: underline;' href="http://www.dbForumz.com/PHP-_REQUEST-problem-ftopict131132.html" target="_blank">http://www.dbForumz.com/PHP-_REQUEST-problem-ftopict131132.html</a>
Visit Topic URL to contact author (reg. req'd). Report abuse: <a style='text-decoration: underline;' href="http://www.dbForumz.com/eform.php?p=437578" target="_blank">http://www.dbForumz.com/eform.php?p=437578</a><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |
External

Since: Jul 05, 2004 Posts: 107
|
(Msg. 8) Posted: Tue Jul 20, 2004 10:54 am
Post subject: Re: $_REQUEST problem [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
.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<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: $_REQUEST problem |
|
| Back to top |
|
 |  |
| Related Topics: | UTF-8 Problem - Hi... I've got a silly problem. I'm using a MySQL 4.1 with UTF-8 charset. phpMyAdmin with UTF-8 charset aswell. The problem is when I enter data in phpMyAdmin or any other MySQL tool, I can't see non standard letter in my app. But when I enter..
UTF-8 Problem - Hi... I've got a silly problem. I'm using a MySQL 4.1 with UTF-8 charset. phpMyAdmin with UTF-8 charset aswell. The problem is when I enter data in phpMyAdmin or any other MySQL tool, I can't see non standard letter in my app. But when I enter data....
PHP 4 OOP problem - Hey all, I wrote a class to represent a node in a site navigation tree which contains methods for building the tree from the database. I also wrote some routines to print out the whole tree, starting from the root. This malfunctions in a weird way in...
serious problem need help. - Hi all, I'm having troubles with my hosting and for a few reasons I can't change. So here is my problem: I receive XML files with images included in the file. I've to parse the file, save datas in a database and save images after resizing them. The..
telnet problem with PHP - I'm writing a little script for reading information from a router by telnet. I have a problem How give a comand and get the answer more times? I means: [...] $usenet = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut); [...] fw... |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|