I want to update the lastlogin column value .i wrote the code like this ,but column is nt updated .i wrote the some code in main.js for inserting query.here i didnt wrote any code for updating the lastlogin column value in main.js.
for updating the lastlogin column i wrote the updatelogin function in the dbfunc.php as below.
function updatelogin($lastlogin)
{
alert("hi");
$query="UPDATE users set last_login='$lastlogin' where email='".$email."'";
$queryresult= mysql_query($query);
$count=mysql_num_rows($queryresult);
if($count>0)
{
return 1;
}
else
{
return 0;
}
}
function register($details_arr)
{
$emailcheck=db_func::checkemail($details_arr['email']);
if($emailcheck == 0){
//print_r($details_arr);
$regemail=$details_arr['email'];
$regpwd=$details_arr['password'];
$zip=$details_arr['zip'];
$secqun=$details_arr['secqun'];
$answer=$details_arr['answer'];
$now=date("Y-m-d H:i:s",time());
$lastlogin=date("Y-m-d H:i:s",time());
$query= "INSERT INTO users (email,md5pwd,zip,squestion,sanswer,member_since,last_login,last_ip) VALUES('".$regemail."','".$regpwd."','".$zip."','".$secqun."','".$answer."','".$now."','".$lastlogin."','".$_SERVER['REMOTE_ADDR']."')";
$queryresult=mysql_query($query);
echo mysql_error();
if($queryresult)
{
non_db_func::loginuser($email);
db_func::updatelogin($details_arr['lastlogin']);
return 1;
}
else
return 0;
}
else{
return 2;
}
can any one tell me ,why lastlogin column isnt updated in my db
The problem is that in function
updatelogin($lastlogin)you have not defined what$emailwill hold.IF you echo your query after your query update statement (after
$query = UPDATE .....)you will see what your problem is.
Update 1
I think you should have something like this before
$querystatement$email=$details_arr['email'];OR
pass
$emailvalue in function asupdatelogin($lastlogin, $email)