Jump to content

Undefined Index


kagedwebdesign

Recommended Posts

I'm using a PHP call code that loads all of my content into the page.  i have used this code many times before, and even in earlier versions of this website and have never had any problems...i was wondering if you could shed some light on this...this is the error I'm getting...

Notice: Undefined index: id in C:\WAMP\Apache Software Foundation\Apache2.2\htdocs\damichigan.com\development\index.php on line 97

 

The code for the page is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled-1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="anylinkcssmenu.css" />

<script type="text/javascript" src="anylinkcssmenu.js">

/***********************************************
* AnyLink CSS Menu script v2.0- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Project Page at http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm for full source code
***********************************************/

</script>

<script type="text/javascript">

//anylinkcssmenu.init("menu_anchors_class") ////Pass in the CSS class of anchor links (that contain a sub menu)
anylinkcssmenu.init("anchorclass")
</script>
<style type="text/css">
<!--
body {
background-color: #9AEDFF;
margin-left: 0px;
margin-top: 0px;
}
-->
</style></head>
<body><center>
<!-- ImageReady Slices (Untitled-1) -->
<table id="Table_01" width="650" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td colspan="11" background="images/index_01.gif" width="650" height="245">			</td>
</tr>
<tr>
	<td>
		<img id="index_02" src="images/index_02.gif" width="12" height="28" alt="" /></td>
	<td>
		<a href="index.php"><img id="home" src="images/home.gif" width="69" height="28" alt="" border="0" /></a></td>
	<td>
		<img id="index_04" src="images/index_04.gif" width="10" height="28" alt="" /></td>
	<td>
		<a href="#" class="anchorclass" rel="submenu1"><img id="ssd" src="images/ssd.gif" width="143" height="28" alt="" border="0"/></a><br />                                                
<div id="submenu1" class="anylinkcss">
<ul><li><a href="?id=facts">Disability  Facts</a></li>
<li><a href="?id=myths">Top Ten Disabilty Myths</a></li>
<li><a href="?id=rightlawyer">How to Select the Right Lawyer</a></li>
<li><a href="?id=application">The Application Process</a></li>
<li><a href="?id=benefits">Can My Family Get Benefits?</a></li>
<li><a href="?id=afford">What If I Can't Afford a Doctor?</a></li>
</ul></div></td>
	<td>
		<img id="index_06" src="images/index_06.gif" width="10" height="28" alt="" /></td>
	<td>
		<a href="#" class="anchorclass" rel="submenu1"> <img id="firm" src="images/firm.gif" width="101" height="28" alt="" border="0"/></a><br />                                                 
<div id="submenu1" class="anylinkcss">
<ul><li><a href="?id=locations">Locations</a></li>
<li><a href="?id=goals">Our Goals</a></li>
<li><a href="?id=testimonials">Testimonials</a></li>
</ul></div></td>
	<td>
		<img id="index_08" src="images/index_08.gif" width="10" height="28" alt="" /></td>
	<td>
		<a href="#" class="anchorclass" rel="submenu1" ><img id="attorneys" src="images/attorneys.gif" width="70" height="28" alt="" border="0"/></a><br />
<div id="submenu1" class="anylinkcss">
<ul><li><a href="?id=sj">Stuart Johnson</a></li>
<li><a href="?id=dl">Dennis Little</a></li>
<li><a href="?id=mg">Michelle Gottesman</a></li>
<li><a href="?id=dg">Danielle Grassmyer</a></li>
<li><a href="?id=sb">Samantha Ball</a></li>
<li><a href="?id=fc">Frank Cusmano</a></li>
<li><a href="?id=kr">Kiel Roeschke</a></li>
</ul></div></td>
	<td>
		<img id="index_10" src="images/index_10.gif" width="9" height="28" alt="" /></td>
	<td>
		<a href="#" class="anchorclass" rel="submenu1" ><img id="contact" src="images/contact.gif" width="79" height="28" alt="" border="0"/></a><br />
<div id="submenu1" class="anylinkcss">
<ul><li><a href="?id=contact">E-mail</a></li>
<li><a href="?id=contactq">Free Case Evaluation</a></li></ul></div></td>
	<td>
		<img id="index_12" src="images/index_12.gif" width="137" height="28" alt="" /></td>
</tr>
<tr>
	<td colspan="11">
		<img id="index_13" src="images/index_13.gif" width="650" height="27" alt="" /></td>
</tr>
</table>
<table width="650" border="1">
  <tr>
    <td>
<?php
  if ($_GET["id"])
  {
    if (file_exists($_GET["id"] . ".php"))
    {
      include($_GET["id"] . ".php");
    }
    else
    {
      include("error.php");
    }
  }
  else
  {
    include("main.php");
  }
?></td>
  </tr>
</table>
<br />
</center>
<!-- End ImageReady Slices -->
</body>
</html>

 

the link to the site is www.damichigan.com/development

 

thanks!

 

Kyle

Link to comment
https://forums.phpfreaks.com/topic/167657-undefined-index/
Share on other sites

Probably because the index isn't defined....

 

 

 

Associative arrays (which are all arrays in PHP) work by associating a piece of data with another piece.  The piece of data used to find the other data is usually called the key or in some cases the index.

 

 

So, what that means is that error means is that no data exists in the $_GET array that is mapped to the key 'id'.

 

 

 

So, you should check to make sure the key has data with it before using it.  isset

 

 

if(isset($_GET['id']))

Link to comment
https://forums.phpfreaks.com/topic/167657-undefined-index/#findComment-884185
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.