Forum Moderators: coopster
I have a column in a 'users' table with the following properties.
Type: datetime
Null: No
Deafult: 0000-00-00 00:00:00
When I want to add a record into the table through PHPMyAdmin, I click 'insert' and the current date & time appear in the text field, and it enters correctly, and the user works fine.
However, when I want to add a user via a PHP-web form (which is how it *needs* to be), it just enters in 0000-00-00 00:00:00 with no data, which means the user can't login :(
I have tried all sorts of different insert strings...none seem to work.
I have set it so that no value is entered, I have also tried having the current date/time passed to the php-processor page, and tried entering that as a value - still not working.
Any ideas? of how I can get this to work? Any help will be greatly appreciated.
Regards,
William.
Thanks for the replies..I had tried the NOW() & Date feature..neither work!
Below is the part of my code which handles the adding:
} elseif ($action == adddealer) {
$newuser = addslashes($HTTP_GET_VARS['username']);
$newname = addslashes($HTTP_GET_VARS['name']);
$newemail = addslashes($HTTP_GET_VARS['email']);
$newpass = addslashes($HTTP_GET_VARS['password']);
$level = addslashes($HTTP_GET_VARS['level']);$sql = "INSERT INTO users (id,username,password,email,lost_key,lost_date,level,dealer) ";
$sql = $sql . " VALUES ('','$newuser',MD5($newpass),'$newemail','0','NOW()','$level','$newname') ";
$result = mysql_query($sql);
print "Your request to add a user was successful";
Your thoughts would be greatly appreciated.
Regards,
William
The id field is probably set as autoincrement, so you don't need it in your query.
Notice that there must not be any quotes around NOW() in your query. Check with phpMyAdmin.
Also, to check for mysql errors in the PHP code, you can do so :
mysql_query($query) or die('Mysql error:' . mysql_error());
Sorry for the layout, I'm not familiar with BB code yet.
Jocelyn
Thanks for the info - still no joy :(.
Here is the error that I receive:
ERROR: Unknown column 'test' in 'field list' INSERT INTO arctic_dealers (username, password, email, lost_key, lost_date, level, dealer) VALUES ('test',MD5(test),'test@email.com','0',NOW(),'1','Test')
I have realised that it is saying it can't find the column, called 'whatever I enter into the password box'.
Any ideas, how to stop this?
Regards,
William