Forum Moderators: coopster

Message Too Old, No Replies

Undefined index

         

gthri

3:52 am on May 12, 2005 (gmt 0)

10+ Year Member



I have a notice displayed as

Notice: Undefined index: cid in c:\program files\easyphp1-8\www\viewgallery.php on line 8

These are the first few lines of my code

include("config.inc.php");

// initialization
$result_array = array();
$counter = 0;

$cid = (int)($_GET['cid']);
$pid = (int)($_GET['pid']);

how can it be rectified?

-gthri

Blackie

6:35 am on May 12, 2005 (gmt 0)

10+ Year Member



I think $pid is simply not set and you get a warning about this. If everything working fine you can change error_reporting so that the warning is not displayed.

just found the same question from you here :-)
[webmasterworld.com...]

dreamcatcher

7:09 am on May 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use isset()

if (isset($_GET['cid']))
{
$cid = (int)($_GET['cid']);
}
if (isset($_GET['pid']))
{
$pid = (int)($_GET['pid']);
}

Hope that helps.

dc

gthri

7:18 am on May 12, 2005 (gmt 0)

10+ Year Member



Hi
thnks a lot that worked like a charm!

-gthri