[HELP]Datetime mysql table
#1

I use mysql plugin BlueG - version R6

I have the problem:

Pawn code:

PHP код:
new yearmonthdayhourminutesecond;
getdate(yearmonthday), gettime(hourminutesecond);
format(querysizeof(query), "INSERT INTO `%s` (`Name`, `Password`, `Ip`, `Date_Registration`, `Money`, `Score`, `Kills`, `Deaths`) VALUES('%s', md5('%s'), '%s', '%d/%d/%04d' '%02d:%02d:%02d', 0, 0, 0, 0)"TABLE_NAMEname(playerid), inputtextip(playerid), daymonthyearhourminutesecond);
mysql_query(query); 
The problem is in ... Date_Registration

MySQL Debug:

PHP код:
[14:47:25CMySQLHandler::Query(INSERT INTO `Users` (`Name`, `Password`, `Ip`, `Date_Registration`, `Money`, `Score`, `Kills`, `Deaths`) VALUES('Test'md5('testpass'), '127.0.0.1''19/6/2012' '14:47:25'0000)) - Successfully executed
Database:

PHP код:
CREATE TABLE `users` (
`
Namevarchar(24NOT NULL,
`
Passwordvarchar(32NOT NULL,
`
Ipvarchar(16NOT NULL,
`
Date_Registrationdatetime NOT NULL,
`
Moneyint(10NOT NULL,
`
Scoreint(10NOT NULL,
`
Killsint(10NOT NULL,
`
Deathsint(10NOT NULL )
ENGINE=InnoDB DEFAULT CHARSET=latin1
In the database save the date in : 0000-00-00 00:00:00 .... why ?
Reply
#2

Instead of your variables, insert one of these MySQL functions (literal): NOW() or UNIX_TIMESTAMP(). Not sure if any of these work, as I always use plain unix timestamps (https://sampforum.blast.hk/showthread.php?tid=254915).

So your query will look like:
PHP код:
INSERT INTO `%s` (`Name`, `Password`, `Ip`, `Date_Registration`, `Money`, `Score`, `Kills`, `Deaths`) VALUES('%s'md5('%s'), '%s'NOW(), 0000); 
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Instead of your variables, insert one of these MySQL functions (literal): NOW() or UNIX_TIMESTAMP(). Not sure if any of these work, as I always use plain unix timestamps (https://sampforum.blast.hk/showthread.php?tid=254915).

So your query will look like:
PHP код:
INSERT INTO `%s` (`Name`, `Password`, `Ip`, `Date_Registration`, `Money`, `Score`, `Kills`, `Deaths`) VALUES('%s'md5('%s'), '%s'NOW(), 0000); 
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)