sqlsrv_has_rows() 错误 PHP 与 MSSQL
sqlsrv_has_rows() ERROR PHP with MSSQL
我的 php 页面有点问题,我就是不明白。我是新来的,我真的不明白我的查询。当我尝试执行我的程序时,出现这样的错误
Warning: sqlsrv_has_rows() expects parameter 1 to be resource, boolean
given
这是我的代码:
<?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 资源集 ID ?
我的 php 页面有点问题,我就是不明白。我是新来的,我真的不明白我的查询。当我尝试执行我的程序时,出现这样的错误
Warning: sqlsrv_has_rows() expects parameter 1 to be resource, boolean given
这是我的代码:
<?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 资源集 ID ?