Z. Zeff Z. Zeff - 6 months ago 17
PHP Question

SQL + PHP Update query

I've been trying to update my data according to the user session (UserLogin) but it kept saying: Data type mismatch in criteria expression. The

print_r
is just for testing purposes.

Thanks in advance,

Z

function Employee1_BeforeShow(& $sender)
{
$Employee1_BeforeShow = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $Employee1; //Compatibility


$Page = CCGetParentPage($sender);

$db = $Page->Connections["PettyCashMDB"];

$sql1 = "UPDATE Employee SET Employee.LastActive = Date() WHERE Employee.[EmpID] = ". $_SESSION['UserLogin'];
$db->query($sql1);

print_r($_SESSION['UserLogin']);



$db->close();
Employee1_BeforeShow @67-67106FAD
return $Employee1_BeforeShow;
}


EDIT: I've tried @NanaPartykar 's method and by accident I've noticed that it does get the value from
$_SESSION['UserLogin']
, just that somehow the datatype is different.

EDIT: It displays the error
Data type mismatch
but both of them are string and returns string.

Answer

Finally got it to work, this is the code $sql1 = "UPDATE Employee SET LastActive = Date() WHERE EmpID = '$_SESSION[UserLogin]' "; Thanks to everyone that helped out.

Comments