我遇到了一段代码的问题。我有一个表单将信息提交给MySQL数据库。我已经将产品密钥保存在数据库中。我想检查数据库中是否存在密钥。我使用下面的代码:检查产品密钥是否已经存在于数据库中?
$namecheck = mysql_query("SELECT key FROM license_key WHERE key ='$userEnteredProductKey'");
$count = mysql_num_rows($namecheck);
if($count)
{
die("FAILURE - <b>$product_name</b> has <b>NOT</b> been added because the reference number already exists.");
}
如果我运行程序它给我的错误是:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in code.
希望是有道理的,任何帮助,不胜感激。
这意味着您的查询返回任何内容。检查查询。的 – 2013-03-15 11:28:47
可能重复的[MySQL的\ _fetch \ _array()预计参数1是资源,在布尔选择给定](http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to -be-resource-boolean-given-in-select) – deceze 2013-03-15 11:29:28
那么我必须使用哪个查询? – Apb 2013-03-15 11:29:54