HOME > PHP > PHP Forum > ช่วยดูให้หน่อยคับ Warning: mssql_query() [function.mssql-query]: message: An expression of non-boolean type specified in a context where a
ช่วยดูให้หน่อยคับ Warning: mssql_query() [function.mssql-query]: message: An expression of non-boolean type specified in a context where a
Warning: mssql_query() [function.mssql-query]: message: An expression of non-boolean type specified in a context where a condition is expected, near 'Name'. (severity 15)
Warning โค้ดบรรทัดที่ 10
Code (PHP)
$servername = "------";
$myUser = "sa";
$myPass = "53123";
$databasename = "EmployeeDB";
$connection_string = "DRIVER={SQL Server};SERVER=$servername;DATABASE=$databasename;AutoTranslate=no";
$cid = odbc_connect($connection_string,$myUser, $myPass);
$strSQL = "SELECT * FROM Base_Emp WHERE Eng First Name = '".trim($_POST['txtUsername'])."'
and Emp ID = '".trim($_POST['txtPassword'])."'";
//$strSQL = "SELECT * FROM Base_Emp ";
$objQuery = mssql_query($strSQL)or die ("Error Query [".$strSQL."]") ;
$objResult = mssql_fetch_array($objQuery);
if(!$objResult)
{
echo "Username หรือ Password ไม่ถูกต้อง!";
}
else
{
$_SESSION["member_id"] = $objResult["Emp ID"];
$_SESSION["member_user"] = $objResult["Eng First Name"];
$_SESSION["member_pass"] = $objResult["Emp ID"];
$_SESSION["member_name"] = $objResult["Eng First Name"];
$_SESSION["member_status"] = $objResult["Div Code"];
session_write_close();
header("location:home.php");
}
odbc_close($cid);
?>