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
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
Share on other sites

like so?

 

DELETE FROM pacienti WHERE pacientID='
Notice: Undefined variable: rows in ...../administrare.php on line 83
'

 

and line 83 is this:

 

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

Link to comment
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
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
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
Share on other sites

Please provide more information.

1. are there any errors: first SQL, second SQL; is $pacientID non empty?

2. are records from 'internari' deleted or not

3. are there any other foreign keys associated to "pacienti"

4. other messages, notices,...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.