Undefined index
Posted: Mon Mar 22, 2010 11:33 am
I keep getting this error when i run my webpage on my localhost.
Notice: Undefined index: pid in C:\wamp\www\index.php on line 6
This is my code for this part:
//This is the body.............................................
if(!$_GET['pid']){ <===== LINE 6
$pageid='1';
}else{
$pageid=$_GET['pid'];
}
//Query the body..............................................................
$sqlCommand="SELECT pagebody FROM pages WHERE id='$pageid' LIMIT 1";
$query=mysqli_query($mysqlcon,$sqlCommand) or die(mysqli_error());
while($row=mysqli_fetch_array($query)){
$Body=$row["pagebody"];
}
mysqli_free_result($query);
//End of body..........................................................................
I dont understand why it says undefined since i thought if there was no get pid then it would automatically make pageid=1
The script runs fine when i click on a link to define the pid but when i just go straight to the script from localhost i get this notice.
Notice: Undefined index: pid in C:\wamp\www\index.php on line 6
This is my code for this part:
//This is the body.............................................
if(!$_GET['pid']){ <===== LINE 6
$pageid='1';
}else{
$pageid=$_GET['pid'];
}
//Query the body..............................................................
$sqlCommand="SELECT pagebody FROM pages WHERE id='$pageid' LIMIT 1";
$query=mysqli_query($mysqlcon,$sqlCommand) or die(mysqli_error());
while($row=mysqli_fetch_array($query)){
$Body=$row["pagebody"];
}
mysqli_free_result($query);
//End of body..........................................................................
I dont understand why it says undefined since i thought if there was no get pid then it would automatically make pageid=1
The script runs fine when i click on a link to define the pid but when i just go straight to the script from localhost i get this notice.