3 Replies - 740 Views - Last Post: 21 February 2013 - 11:12 PM Rate Topic: -----

#1 nazirul_137  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 15
  • Joined: 06-February 13

Get Notice: Undefined index

Posted 21 February 2013 - 07:50 PM

why i get notice from line 28 and 29???
<html>  
<head>  
<title>Testing Retrieve</title>  
</head>  
<body>  
<?php 
$conn = oci_connect("USER", "PASSWORD", "PATH");  
$strSQL = "SELECT * FROM TB_AGENCY";
$objParse = oci_parse($conn, $strSQL);  
oci_execute ($objParse,OCI_DEFAULT);  
?>  
<table width="900" border="1" bordercolor="#000000">  
<tr>  
<th width="198"><div align="center">PARTNER CODE</div></th>  
<th width="198"><div align="center">AGENCY CODE</div></th>  
<th width="198"><div align="center">TCONTACT DATE</div></th>  
<th width="198"><div align="center">UPDATE DATE</div></th>  
<th width="198"><div align="center">UPDATE TIME</div></th>  
<th width="198"><div align="center">PARTNER TYPE</div></th>  
</tr>  
<?php 
while($objResult = oci_fetch_array($objParse,OCI_BOTH))  
{  
?>  
<tr>  
<td><div align="center"><?php echo $objResult["PTNR_CODE"];?></div></td>  
<td><div align="center"><?php echo $objResult["AGENCY_CODE"];?></div></td>  
<td><div align="center"><?php echo $objResult["FCONTACT_CODE"];?></div></td>  
<td><div align="center"><?php echo $objResult["TCONTACT_CODE"];?></div></td>  
<td align="right"><div align="center"><?php echo $objResult["UPDATE_TIME"];?></div></td>  
<td align="right"><div align="center"><?php echo $objResult["PTNR_TYPE"];?></div></td>  
</tr>  
<?php
}  
?>  
</table>  
<?php
oci_close($conn);  
?>  
</body>  
</html>

This post has been edited by GunnerInc: 21 February 2013 - 07:57 PM
Reason for edit:: code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Get Notice: Undefined index

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,204
  • Joined: 19-January 10

Re: Get Notice: Undefined index

Posted 21 February 2013 - 07:54 PM

Put your code in the code tags.

Undefined index is when you try to access a variable in an associative array using a key that doesn't exist.

Incorrect code:
$fruit_count = array("apple" => 3, "pears" => 2);
echo 'We have ' . $fruit_count['banana'] . ' apples left'; // Throws Undefined Index



Correct code:
$fruit_count = array("apple" => 3, "pears" => 2);
echo 'We have ' . $fruit_count['apple'] . ' apples left'; // "We have 3 apples left"


This post has been edited by creativecoding: 21 February 2013 - 07:55 PM

Was This Post Helpful? 0
  • +
  • -

#3 nazirul_137  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 15
  • Joined: 06-February 13

Re: Get Notice: Undefined index

Posted 21 February 2013 - 08:41 PM

then i dont understand why i get Undefined index: txtKeyword from line 2. anybody can explain about this and fix it.i'm new in learning programming. i using oracle database. and i want create the page that searching the data from database.

<?php
if($_GET["txtKeyword"] != "")
	{
	$objConnect = oci_connect("USER", "PASSWORD", "PATH");
	$strSQL = "SELECT  * FROM TB_AGENCY WHERE (PTNR_CODE LIKE '%".$_GET["txtKeyword"]."%' or AGENCY_CODE LIKE '%".$_GET["txtKeyword"]."%' )  ";
	$objParse = oci_parse ($objConnect, $strSQL);
	oci_execute ($objParse);
	?>
	<table width="600" border="1">
	  <tr>
      <th width="198"><div align="center">PARTNER CODE</div></th>  
      <th width="198"><div align="center">AGENCY CODE</div></th>  
      <th width="198"><div align="center">TCONTACT DATE</div></th>  
      <th width="198"><div align="center">UPDATE DATE</div></th>  
      <th width="198"><div align="center">UPDATE TIME</div></th>  
      <th width="198"><div align="center">PARTNER TYPE</div></th>
	  </tr>
	<?php
	while($objResult = oci_fetch_array($objParse,OCI_BOTH))
	{
	?>
	  <tr>
		<td><div align="center"><?php echo $objResult["PTNR_CODE"];?></div></td>
		<td><?php echo $objResult["AGENCY_CODE"];?></td>
		<td><?php echo $objResult["FCONTACT_DATE"];?></td>
		<td><div align="center"><?php echo $objResult["TCONTACT_DATE"];?></div></td>
		<td align="right"><?php echo $objResult["UPDATE_TIME"];?></td>
		<td align="right"><?php echo $objResult["PTNR_TYPE"];?></td>
	  </tr>
	<?php
	}
	?>
	</table>
	<?php
	oci_close($objConnect);
}
?>

<html>
<head>
<title>Testing Search</title>
</head>
<body>
<form name="frmSearch" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
  <table width="599" border="1">
    <tr>
      <th>Keyword
      <input name="txtKeyword" type="text" id="txtKeyword" value="<?php echo $_GET["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
</body>
</html>

This post has been edited by Dormilich: 21 February 2013 - 11:10 PM
Reason for edit:: please use [code] [/code] tags when posting code

Was This Post Helpful? -1
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3490
  • View blog
  • Posts: 10,058
  • Joined: 08-June 10

Re: Get Notice: Undefined index

Posted 21 February 2013 - 11:12 PM

View Postnazirul_137, on 22 February 2013 - 04:41 AM, said:

then i dont understand why i get Undefined index: txtKeyword from line 2.

well, there seems to be no "txtKeyword" index in the $_GET array.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1