Storing connections.
#1

I'm trying to store Name, IP and Date into a "connections" table in mysql however it doesn't seem to work. IP comes out as "49" and date is "0000-00-00".

pawn Код:
new ip[16], hour, minute, second;
    GetPlayerIp(playerid, ip, sizeof(ip));
   
    gettime(hour, minute, second);
   
    format(query, sizeof(query), "INSERT INTO `connections` (`Name`, `IP`, `Date`) VALUES ('%s', '%s', '%d:%d:%d')", GetName(playerid), ip, hour, minute, second);
    mysql_tquery(sqldb, query, "Query", "i", playerid);
IP: Set to varchar of 16. Date set to DATE in table.

P.S, Name works.
Reply
#2

Varchar16 should be correct. However, I recommend you use one of MySQL's many date functions. You can even set the default value for the column to the current timestamp.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Varchar16 should be correct. However, I recommend you use one of MySQL's many date functions. You can even set the default value for the column to the current timestamp.
Yeah, I've just changed the Date to:
Type | Collation Null Default
Date timestamp No CURRENT_TIMESTAMP

The IP seems to store, but the date doesn't.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)