mysql timestamp problem -
Vivaz - 10.03.2013
Hello. I had a mysql timestamp problem. I create mysql tables - Timesta(TIMESTAMP) and Expire(TIMESTAMP)
Now i'am creating code who check time expires or not.
Код HTML:
stock VipCheck2(playerid)
{
new
sql[ 128 ];
format ( sql, sizeof ( sql ), "SELECT * FROM vips WHERE Vipas = '%s'", pName(playerid) );
mysql_query( sql );
mysql_store_result( );
while(mysql_retrieve_row()){
new expire;
mysql_fetch_field_row ( sql , "Expire" ) ;
expire = strval(sql);
if(gettime() >= expire)
{
PlayerInfo[playerid][pVip] = false;
M(playerid,"Vip time expires!");
//format(jQuery,MAX_QUERY_LENGTH,"DELETE FROM vips WHERE Vipas='%s'",pName(playerid));
//mysql_query(jQuery);
}
}
I create 1sec timer who check.
But when i put 1000sec. After 1sec i got message "vip time expires". Anyone can help me? And sorry for bad english
Re: mysql timestamp problem -
IceCube! - 10.03.2013
Okay this may just be me but I cant read code that isn't indented place your code inside [pawn] brackets the second with /pawn.
Once you've done this I'll be able to read it and help you, sorry if this annoys anyone.
Re: mysql timestamp problem -
Vivaz - 10.03.2013
I'am sorry
Re: mysql timestamp problem -
Vivaz - 10.03.2013
Anyone can help?
Re: mysql timestamp problem -
Vivaz - 11.03.2013
Help please
Re: mysql timestamp problem -
Djole1337 - 11.03.2013
Make sure you insert something like
gettime()+86400 = 1 day VIP.
Re: mysql timestamp problem -
Vivaz - 11.03.2013
There is problem with check code.
Re: mysql timestamp problem -
Vivaz - 11.03.2013
if(gettime() >= expire) i think there is problem, this only check time. I need check date + time but i dont know how.
Re: mysql timestamp problem -
Sergei - 11.03.2013
Код:
"SELECT *, UNIX_TIMESTAMP(Expire) AS expire_unix FROM vips WHERE Vipas = '%s'"
Then fetch `expire_unix` and commpare with gettime().
However, even better solution is this (for advanced users):
Код:
DELETE FROM vips WHERE Vipas='%s' AND NOW() >= Expire
Then simply check with mysql_affected_rows if there were any rows deleted and make your changes in PAWN.
Re: mysql timestamp problem -
Vivaz - 11.03.2013
Doesn't works. I think there is problem gettime() becouse it only check time, but when i put vip time it will be current time with date ant time.