Mysqli在插入数据库之前检查重复项

时间:2015-12-21 17:30:24

标签: php mysqli duplicates

大家好,我有以下类似的代码,曾经在旧版本的PHP上工作,因为现在更新使用mysqli代码似乎不起作用,任何帮助表示赞赏..

    $result = mysql_query($connection,"SELECT * FROM listing_1 WHERE product_code='$product_code'");

    $num_rows = mysqli_num_rows($result);
    if ($num_rows) {

    adminwarnmessage("DUPLICATE REFERENCE CODE","FAILURE - <b>$product_name</b> has <b>NOT</b> been added because the reference number already exists.<p><a href=\"javascript: history.go(-1)\" class=\"buttonPro red\">Go Back</a> to go back and enter a <b>different</b> reference number.</p>");

}

0 个答案:

没有答案