何らかの理由で、このコードは1の代わりに2を返しますか?
やろうとして何イム$allowedCount = 1; (This figure is set inside the database)
$sql_count = mysql_query("SELECT usrid FROM mytable WHERE usrid=".$uid) or die(mysql_error());
$currentCount = mysql_num_rows($sql_count);
$currentCount = 1; (In this example current count returns a 1)
if ($currentCount <= $allowedCount) {
// do this OK
} else {
// do this Not OK
}
は、ユーザーが自分の限界に達していればそうそして、彼らにさらにINSERTクエリなどを禁止している場合、チェックです....
これは単純なアプローチでしょうか?
あなたの 'SELECT'で' COUNT(*) 'を使わないのはなぜですか? –
どこから$ uidを取得するかによって、これは潜在的なSQLインジェクションの脆弱性の可能性があります。参照してください:http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php – DGM