1

I have a problem executing this code.
It shows this error every time:

Notice: Undefined variable: objResult in C:\wamp\www\delete.php on line 26 

Also the same on line 27,28,29 and 30.

This is the table I am working on:

SQL> desc etudiant;
Nom                                       NULL ?   Type
----------------------------------------- --------  ----------------------------
NUM                                       NOT NULL NUMBER
NOM                                                VARCHAR2(15)
PRENOM                                             VARCHAR2(15)
DATE_NAISSENCE                                     DATE
ADRESSE                                            VARCHAR2(30)

delete.php sample

<html>  
<head>  
<title>DELETE ROW</title>  
</head>  
<body>  
<?  
$objConnect = oci_connect("alaa94", "red1", "orcl");   
$strSQL = "SELECT * FROM etudiant";  
$objParse = oci_parse ($objConnect, $strSQL);  
oci_execute ($objParse,OCI_DEFAULT);  
?>  
<table width="600" border="1">  
<tr>  
<th width="91"> <div align="center">Num </div></th>  
<th width="98"> <div align="center">Nom </div></th>  
<th width="198"> <div align="center">Prenom </div></th>  
<th width="97"> <div align="center">Date_naiss </div></th>  
<th width="59"> <div align="center">adresse </div></th>  
</tr>  
<?  
while($objResult = oci_fetch_array($objParse,OCI_BOTH))  
{  
?> 

<tr>  
<td><div align="center"><?=$objResult["num"];?></div></td>  
<td><?=$objResult["nom"];?></td>  
<td><?=$objResult["prenom"];?></td>  
<td><div align="center"><?=$objResult["date_naissence"];?></div></td>  
<td align="right"><?=$objResult["adresse"];?></td>  

<td align="center"><a href="delete2.php?numID=<?=$objResult["num"];?>">Delete</a></td>  
Confirm Delete  
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='delete2.php?numID=<?=$objResult["num"];?>';}">Delete</a></td>  

</tr>  
<?  
}  
?>  
</table>  
<?  
oci_close($objConnect);  
?>  
</body>  
</html>  

And this is delete2.php sample

<html>  
<head>  
<title>DELETE ROW</title>  
</head>  
<body>  
<?  
$objConnect = oci_connect("alaa94", "red1", "orcl");  
$strSQL = "DELETE FROM etudiant ";  
$strSQL .="WHERE num = '".$_GET["numID"]."' ";  
$objParse = oci_parse($objConnect, $strSQL);  
$objExecute = oci_execute($objParse, OCI_DEFAULT);  
if($objExecute)  
{  
oci_commit($objConnect); //*** Commit Transaction ***//  
echo "Record Deleted.";  
}  
else  
{  
oci_rollback($objConnect); //*** RollBack Transaction ***//  
$e = oci_error($objParse);  
echo "Error Delete [".$e['message']."]";  
}  
oci_close($objConnect);  
?>  
</body>  
</html>  
APC
  • 144,005
  • 19
  • 170
  • 281
Androider
  • 11
  • 3

0 Answers0