Page 1 of 1

error solving...

Posted: Fri May 21, 2004 9:20 am
by kevin7
$id = $_REQUEST['id'];

i've declared the variable from above...
after i clicked the link with query string ...

http://domain/sales.php?id=1000

then, it will show the employee sales with id 1000...

but, if i click on the link without query string...
the error msg will come out..

Notice: Undefined index: id in c:\inetpub\wwwroot\mc\sales.php on line 11

... can i ignore the error? simply bypass it without showing to the user?

tq~!

Posted: Fri May 21, 2004 9:44 am
by zenabi
Yes you can configure PHP to only show certain error types (therefore, in your case, not show Notice errors). See http://uk2.php.net/error-reporting

You can also set it globally by changing the value in your php.ini file.

Posted: Fri May 21, 2004 9:50 am
by jason
Yes, you can ignore it, but you would be better off solving the problem rather than ignoring it.

Just do:

Code: Select all

$id = (isset($_REQUEST['id']) ? $_REQUEST['id']: null);
The Notice that you are getting (it's not an error) basically means you are using a variable that doesn't exist ($_REQUEST['id']). It doesn't exist when you don't pass it via the URL because, well, it doesn't exist. Using isset() checks if it exists or not.

The other way is to reduce your [php_man]error_reporting[/php_man] level, but that only hides the notice, doesn't solve the problem.