mysql_num_rows に問題があります。ログインしようとすると、次の警告が表示されます。
警告: mysql_num_rows() は、パラメーター 1 がリソースであると想定します。オブジェクトは、行 #no の path/to/userClass.php で指定されます。
そのエラーを検索したところ、間違ったSQLクエリが原因であることがわかりました。しかし、私はそれについて確信が持てません。助けてください。
ユーザークラス.php
ログイン機能
$sql = "SELECT id, username FROM `user` WHERE username = '$username' AND hashed_password ='$password'";
$result = mysqli_query( $this->con, $sql );
if ( !$result ) die ("Database query failed" . mysql_error());
else{
$count = mysql_num_rows( $result );
if( $count == 1 ){
$found_user = mysql_fetch_array( $result );
$_SESSION['user_id'] = $found_user['id'];
$_SESSION['username'] = $found_user['username'];
header( "Location:{$location}" );
}else{
//username/password combo was not found in the database
$this->pass_notverified = "Username/password incorrect.";
return;
}
}
header.php
<?php require_once 'class/userClass.php';?>
<?php $obj = new userClass;?>
<?php
if( isset( $_POST['login'] ) ){
$obj->login( $_POST,"home.php" );
}?>