error solving...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

error solving...

Post 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~!
zenabi
Forum Commoner
Posts: 84
Joined: Mon Sep 08, 2003 5:26 am
Location: UK

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post 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.
Post Reply