|
|
|
|
![]() ![]() |
Jun 10 2008, 11:46 AM
Post
#1
|
|
|
Kinda N00B Group: Members Posts: 230 Joined: 13-January 08 From: Sweden Member No.: 27,579 |
Hi again.
I am trying to make a new Register script. But now, there is only one thing that is not working.. I can't make the following query work. CODE mysql_query("INSERT INTO members(username, password, email, register_date) VALUES ('$user','$pass','$email', '$reg_date')") or die("Failed to register.<br> Error:".mysql_error()); this is the current date variable, that is causing the error. (if I remove it from the query, it works just fine) CODE $reg_date=date("Y/m/d"); this is the error I am getting: QUOTE Error:Data truncated for column 'register_date' at row 1 in the database I gave it the data type int, because the date is only made out of numbers. Thanks for your help //Feelay This post has been edited by Feelay: Jun 11 2008, 07:39 AM |
|
|
|
Jun 13 2008, 10:13 AM
Post
#2
|
|
|
Super Member Group: [HOSTED] Posts: 763 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
Your query don't work because your variable stores a string like "2008/06/13", the "/" character cause this error to happen.
To fix it simply change your variable's date format to: CODE <?php $reg_date=date("Ymd"); ?> But this can lead to get problems with the register_date field, i'm not sure about this. A better solution is to change the data type of the register_date field to date and change the sql query to: CODE <?php mysql_query("INSERT INTO members(username, password, email, register_date) VALUES ('$user','$pass','$email', NOW())") or die("Failed to register.<br> Error:".mysql_error()); ?> Best regards, |
|
|
|
Jun 13 2008, 11:32 AM
Post
#3
|
|
|
Kinda N00B Group: Members Posts: 230 Joined: 13-January 08 From: Sweden Member No.: 27,579 |
Thanks ^.^
lol Anyways.. it is working now =) Thank you //Feelay |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 14th October 2008 - 01:51 AM |