I wrote a function to fetch the user_status from SQL Server but its seems everything is correct but still I am not getting any output.
My connection with SQL Server is established. And my function is as follows:
function fetchuserStatus($username,$password) {
include("db-settings.php");
if ($conn) {
$sql = "SELECT User_status from _yb_all_users_tbl where User_name = ? AND Password = ?";
$parameters = array($username,$password);
$stmt = sqlsrv_query($conn, $sql, $parameters);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
if(sqlsrv_has_rows($stmt) === true) {
sqlsrv_fetch($stmt);
}
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
} else {
echo "Connection is not established";
}
}
echo fetchuserStatus($username,$password);
And my db-settings.php file is:
$serverName = ".";
$connectionOptions = array(
"Database" => "yaadbook",
"UID" => "sa",
"PWD" => "shiftu"
);
$conn = sqlsrv_connect( $serverName, $connectionOptions);
if($conn) {
} else {
echo "Connection Failure";
die(print_r(sqlsrv_errors(),TRUE));
}
I am using PHP version 7.1.12. How can I resolve this issue?