Thread: error when $_POST is not present
Results 1 to 5 of 5
Related
-
Parse error, parse error unexpected T_variable. Help appreciated! Forum: PHP Forum
Replies: 8 -
DB-Library error: General SQL Server error: Check messages from the SQL Server. Forum: General Discussion
Replies: 0 -
What made you choose your present web host? Forum: Web Hosting Forum
Replies: 2 -
For how long are you with your present host? Forum: Web Hosting Forum
Replies: 0 -
Error MySQL Error: 1064 - subqueries Forum: PHP Forum
Replies: 0
-
01-26-2006, 06:52 AM #1
error when $_POST is not present
How can I get over the error when an expected variable is not passed in the URL?
In my script I have 2 variables, either of which may be passed in the url or none at all.
The page is capable of rendering without them except an error is producted "undefined index
in ProdID.
Here is the part causing the problem:
PHP Code:if ($_REQUEST)
{
$ProdID = $_REQUEST['ProdID'];
true due to the other variable being passed.
I need to be able to say:
If $REQUEST contains 'ProdID' (regardless of whether anyother elements are present), then {}
Thanks in advance
pete
-
01-26-2006, 08:16 AM #2
Re: error when $_POST is not present
Here is a better way of coding that:
Code:$ProdID = $_REQUEST['ProdID']; if ($ProdID = "") { //error logic here } else { // normal processing }
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
-
01-26-2006, 07:38 PM #3
Re: error when $_POST is not present
Originally Posted by vinyl-junkie
PHP Code:$ProdID = $_REQUEST['ProdID'];
However, I eventually found the solution!
I used 'isset()' to determine whether the 'ProdID' was passed or not
Here's how I used it
PHP Code:<?
if (isset($_REQUEST['deleted']))
{
$deleted = $_REQUEST['deleted'];
echo "$deleted";
}
?>
peter
-
01-26-2006, 11:03 PM #4
Re: error when $_POST is not present
Thanks for letting us know how you finally solved the problem. I am sure others will find it of help.
Dave
-
01-27-2006, 06:31 AM #5
Re: error when $_POST is not present
I tend to use the negative test ...
PHP Code:if (!$_REQUEST['ProdID']) {
//error code goes here
//exit script if required ...
}
$ProdID = $_REQUEST['ProdID'];
//Carry on with the page
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum