我想在同一时间删除与患者ID相关的患者记录和任何约会,但都没有工作,有人可以告诉我我要去哪里吗?内部加入删除不起作用
我的代码是:
<?php
include("includes/staffmenu.php");
include("includes/staffsession.php");
@require_once("includes/dbconfig.inc");
$patid = $_GET['patid'];
$patientname = mysql_query("SELECT * From patient WHERE Patient_ID=$patid");
while($row = mysql_fetch_array($patientname))
{ $pfname=$row['Patient_First_Name'];
$pmname=$row['Patient_Middle_Name'];
$psname=$row['Patient_Surname'];
}
echo "<h1>Success $pfname $pmname $psname (Patient ID: $patid) has been removed from our database, along with any appointments in their name</h1>";
mysql_query("DELETE FROM appointment, patient
USING patient INNER JOIN appointment ON (patient.Patient_ID = appointment.Patient_ID)
WHERE patient.Patient_ID='$patid'");
?>
这肯定得到的病人ID,因为患者ID的名称相呼应,很好...
它甚至工作,如果你手动运行查询? – Sebas 2013-03-17 18:35:14
注意:考虑使用参数而不是直接输入,或者让自己开放给sql注入,特别是因为你直接从GET获取patid http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection -in-php – Christian 2013-03-17 18:44:29
@Sebas通过手动删除你的意思是来自phpMyAdmIn吗?如果是的话,它从那里工作正常... – 2013-03-17 18:51:49