This topic is locked

Beginners question

8/17/2006 11:30:22 AM
PHPRunner General questions
W
wilco muns author

Hello,
I want to know when a user logs in.

This must be set in the tabel _Login.

The date/time field is called Laatste_login.

I programed it using the Events option
function AfterSuccessfulLogin()

{

//** Custom code ****

// put your custom code here

UPDATE _Login SET Laatste_login=NOW()

WHERE id='$id';
}
When adding this code it generates a error: Parse error: syntax error, unexpected T_STRING in ........

What is wrong?

I am a beginners, so it bust be something simpel (i hope...).

kujox 8/17/2006

function AfterSuccessfulLogin()

{

//** Custom code ****

// put your custom code here

UPDATE _Login SET Laatste_login=NOW()

WHERE id='$id';
}


you just missed a few bits out
Try this, it might work, I've not really used the now function so I didn't include it.
if you dont what the full timestamp then drop the H:i:s in the date command
function AfterSuccessfulLogin() {

global $conn;

$now_time = date("Y-m-d H:i:s");// this is the time stamp

$strSQLupdate = "UPDATE _Login SET Laatste_login='$now_time' WHERE username=" . $_SESSION["UserID"];// this is the query string

db_exec($strSQLupdate,$conn);// execute the query and trap the errors

}

W
wilco muns author 8/17/2006

[you just missed a few bits out
Try this, it might work, I've not really used the now function so I didn't include it.
if you dont what the full timestamp then drop the H:i:s in the date command
function AfterSuccessfulLogin() {

global $conn;

$now_time = date("Y-m-d H:i:s");// this is the time stamp

$strSQLupdate = "UPDATE _Login SET Laatste_login='$now_time' WHERE username=" . $_SESSION["UserID"];// this is the query string

db_exec($strSQLupdate,$conn);// execute the query and trap the errors

}
Hello,
When trying this i get te following error:

Fatal error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'muns' at line 1 in /public_html/admin/include/dbconnection.php on line 26

kujox 8/17/2006

When trying this i get te following error:

Fatal error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'muns' at line 1 in /public_html/admin/include/dbconnection.php on line 26


is muns the user that has just logged in? just swap the query string line for this one
$strSQLupdate = "UPDATE _Login SET Laatste_login='$now_time' WHERE username='" . $_SESSION["UserID"]."'";// this is the query string

W
wilco muns author 8/17/2006



is muns the user that has just logged in? just swap the query string line for this one
$strSQLupdate = "UPDATE _Login SET Laatste_login='$now_time' WHERE username='" . $_SESSION["UserID"]."'";// this is the query string


Thanks!!

It works perfect now!

kujox 8/17/2006

glad to help.