Insert Date

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Insert Date

Post by AliasBDI »

I have some code which I thought would enter the current date and time into a field called "signup_date". Can someone check my query to figure out where the bad code is?

Code: Select all

$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, signup_date, decrypted_password, address, city, state, zip, phone1, phone2, dl, birth, newsletter, active)
		VALUES('$first_name', '$last_name', '$email_address', '$username', '$password_encrypt', now(), '$password', '$address', '$city', '$state', '$zip', '$phone1', '$phone2', '$dl', '$birth', '$newsletter', '$active')") or die (mysql_error());
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Is there an error? What exactly is going wrong?

Mac
User avatar
Slyvampy
Forum Newbie
Posts: 23
Joined: Thu Nov 28, 2002 2:03 am
Location: Yorkshire, England
Contact:

Post by Slyvampy »

"now()"

try putting ' around it ?
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

response

Post by AliasBDI »

twigletmac-
The problem is that it does not put anything in the field so the field goes to default - December 1969 ....

Slyvampy-
I tried the quotations but it did not work either. Same result.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What type of field is signup_date?

Mac
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Post by AliasBDI »

The field is "datetime" field.
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

aiight

Post by AliasBDI »

Got it working... might have been a dumb user error. :wink:
Post Reply