Hi,

I'm making a simple forum.

When a user register's, I trying to create their join date.

CREATE TABLE Users
(
	userName varchar(15) NOT NULL,
	registrationDate datetime default NULL
)

and then have MySQL automatically set that value:

$sql = "INSERT INTO Users (userName, registrationDate)
VALUES ('".$username."' , '".NOW()."')";

The program keeps failing though. when the PHP code is ran it says:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

Am I doing this right?

I think it may be my syntax, but I could be wrong.

Appreciate all help with this. :)

i'm pretty sure now() doesnt need quotes so

$sql = "INSERT INTO Users (userName, registrationDate)
VALUES ('".$username."' , NOW())";
commented: Thanks buddy! +1

It works!

Thanks kireol ! :)

Program working now!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.