Jump to content

DELETE Data


Pandareen

Recommended Posts

It echoes only ERROR and i don't know why?can i get some help please?

 

1.index.php:

...
<tr>
<td width="128"><?php echo $row_Recordset1['pacientID']; ?></td>
<td width="111"><?php echo $row_Recordset1['nume']; ?></td>
<td width="128"><?php echo $row_Recordset1['prenume']; ?></td>
<td width="122"><?php echo $row_Recordset1['cnp']; ?></td>
<td width="192"><?php echo $row_Recordset1['data']; ?></td>
<td width="192"><a href="delete_inregistrare.php?pacientID=<? echo $rows['pacientID']; ?>">Elimiare Pacient</a></td>
</tr>
...

 

2.delete_inregistrare.php

 

<?php
$host="#####"; 
$username="#####";  
$password="######";
$db_name="model_healthcare"; 
$tbl_name="pacienti";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$pacientID=$_GET['pacientID'];

$sql="DELETE FROM $tbl_name WHERE pacientID='$pacientID'";
$result=mysql_query($sql);

if($result){
echo "Deleted Successfully";
}
else {
echo "ERROR";
}

mysql_close();

?>

Link to comment
https://forums.phpfreaks.com/topic/254162-delete-data/
Share on other sites

You are missing the <?php tag, short tags are not enabled on your server:

Change:

 

<td width="192"><a href="delete_inregistrare.php?pacientID=<? echo $rows['pacientID']; ?>">Elimiare Pacient</a></td>

 

to

 

<td width="192"><a href="delete_inregistrare.php?pacientID=<?php echo $rows['pacientID']; ?>">Elimiare Pacient</a></td>

Link to comment
https://forums.phpfreaks.com/topic/254162-delete-data/#findComment-1303042
Share on other sites

i don't need security 'cuz is only a project ( for now ) but thnx.Look what shows with recordset:

 

Cannot delete or update a parent row: a foreign key constraint fails (`model_healthcare`.`internari`, CONSTRAINT `internari_ibfk_1` FOREIGN KEY (`pacientID`) REFERENCES `pacienti` (`pacientID`))

Link to comment
https://forums.phpfreaks.com/topic/254162-delete-data/#findComment-1303050
Share on other sites

$host="localhost"; 
$username="root";  
$password="administrator";
$db_name="model_healthcare"; 
$tbl_name="pacienti";

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$pacientID=$_GET['pacientID'];

$tbl_name = 'internari';
$sql="DELETE FROM $tbl_name WHERE pacientID='$pacientID'";
$result=mysql_query($sql);

$sql2="DELETE FROM $tbl_name WHERE pacientID='$pacientID'";
$result=mysql_query($sql2);

 

i've tried like this but is the same result..no change :(

Link to comment
https://forums.phpfreaks.com/topic/254162-delete-data/#findComment-1303054
Share on other sites

Try with this:

 

$host="localhost"; 
$username="root";  
$password="administrator";
$db_name="model_healthcare"; 


mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$pacientID=$_GET['pacientID'];

$tbl_name = 'internari';
$sql="DELETE FROM $tbl_name WHERE pacientID='$pacientID'";
$result=mysql_query($sql);

$tbl_name="pacienti";
$sql2="DELETE FROM $tbl_name WHERE pacientID='$pacientID'";
$result=mysql_query($sql2);

Link to comment
https://forums.phpfreaks.com/topic/254162-delete-data/#findComment-1303056
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.