Query using sqlsrv in PHP

$serverName = "server";
$connectionInfo = array( "CharacterSet"=>"UTF-8", "Database"=>"***",     "UID"=>"**", "PWD"=>"**");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
function sqlsrv_escape($str) {
  return str_replace("'", "''", $str);
}
if(filter_var($_SESSION['kt_login_user'], FILTER_VALIDATE_EMAIL)) {
$email = $_SESSION['kt_login_user'];
//$date =$_POST['month'].' '.$_POST['year'];
$emp =$_SESSION['kt_staff_id'];
$num=1;
if( $conn==true ) {
    $sql = 'SELECT
dbo.[Data base$Employee].No_ AS empno,
dbo.[Data base$Employee].[First Name] AS fnamae,
dbo.[Data base$Employee].[Middle Name] AS mname,
dbo.[Data base$Employee].[Last Name] AS lname,
dbo.[Data base$Employee].[Phone No_] AS phone,
dbo.[Data base$Employee].[E-Mail] AS email,
dbo.[Data base$Employee].Status AS status
FROM
dbo.[Data base$Employee]
LEFT JOIN dbo.[Data base$Job Titles] ON dbo.[Data base$Employee].[Job Titles] = dbo.[Data base$Job Titles].Code
WHERE
dbo.[Data base$Employee].Status = 0
AND dbo.[Data base$Employee].[E-Mail]= \''.sqlsrv_escape($email).'\''
;
}

Error Message :

Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 156 [code] => 156 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'AS'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'AS'. ) )

Related Articles
You Might Also Like