// Check to see if p_name exists
$sql = mysql_query("SELECT patient_name FROM patient WHERE patient_name = '" . $p_name . "'");
if (mysql_num_rows($sql) == 0){
// patient database
mysql_query("INSERT INTO patient (patient_name)
VALUES ( '$p_name' )") or die (mysql_error());
}
else
die ("Patient name exist!");
为什么即使数据库中存在患者姓名,它仍会插入新记录?
是否if (mysql_num_rows($sql) == 0)
正确?