我想盡快擺脫一個錯誤。我正在使用mysql_num_rows,但它總是返回0.我不知道是否因爲我有錯誤的語法或什麼...你們能幫助我嗎?這是代碼;MYSQLI_NUM_ROWS ALWAYS RETURNING 0
<?php
include_once("checklogin.php");
$u = "";
if(isset($_GET["u"])){
$u = preg_replace('#[^a-z0-9]#i', '', $_GET['u']);
} else {
header("location: http://www.myswesite.com/login.php");
exit();
}
$sql = "SELECT * FROM users WHERE username='$u' AND activated='1' LIMIT 1";
$user_query = mysqli_query($connection, $sql);
$numrows = mysqli_num_rows($user_query);
if($numrows < 1){
echo "User does not exist or is not yet activated, press back";
exit();
}
?>
嘗試直接在MySQL中測試Query,結果是什麼? –
嘗試'if($ numrows == 0)'而不是'if($ numrows <1)' –
這可能是您的preg_replace調用。 – Zarathuztra