mysql timestamp problem
#1

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
Reply
#2

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.
Reply
#3

I'am sorry
Reply
#4

Anyone can help?
Reply
#5

Help please
Reply
#6

Make sure you insert something like

gettime()+86400 = 1 day VIP.
Reply
#7

There is problem with check code.
Reply
#8

if(gettime() >= expire) i think there is problem, this only check time. I need check date + time but i dont know how.
Reply
#9

Код:
"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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)