I'm having a slight problem with my php page which I just don't understand. I'm new in this and i don't really understand my query. When i try to execute my program, error appear like this
Warning: sqlsrv_has_rows() expects parameter 1 to be resource, boolean given
This is my code:
<?php
session_start();
try{
include 'connection.php';
$username = $_POST['user'];
$password = $_POST['pass'];
//check if login form is filled
if(empty($_POST['user']) || empty($_POST['pass'])){
echo '<script type="text/javascript">alert("Connection established."); </script>';
}
//search for user and password in the database
$query = "SELECT * FROM [Emkaandb].[dbo].[tbl_clientslogin] WHERE email='{$username}' AND .password='{$password}' AND active='1'";
$result = sqlsrv_query($conn, $query);
if($result == true){
die(print_r(sqlsrv_errors(),true));
}
if(sqlsrv_has_rows($result) !=1){
echo '<script type="text/javascript">alert("Invalid email or password."); </script>';
}else{
while($row = sqlsrv_fetch_array($result)){
$_SESSION['name'] = $row['name'];
}
header("location: Profile.php");
}
}catch (PDOException $e)
{
echo "Error!: " . $e->getMessage() . "
";
die();
}
?>
$result return resource set id ?