我正在尝试在php中查询数据库并获取是否存在匹配/成功但是它不会导致成功,尽管它应该如此我认为存在语法错误?
以下是代码:
if ($db_found) {
$SQL = "SELECT * FROM wp_users where user_login='.$user.'";
$result = mysql_query($SQL);
//Check if theres a match
if $result > 0 {
echo 'There was a match';
}
...
}
答案 0 :(得分:3)
if (mysql_num_rows($result)) {
echo 'match';
}
答案 1 :(得分:2)
if (mysql_num_rows($result)==1) {
echo 'There was a match';
}