[Tutorial] MySQL ban system using unix timestamps
#7

I give you a tip, when you save the timestamps as unbantime and the bantime about mysql than get the timestamps about MySQL to instead of the function gettime.
Use the SQL-Command NOW() to return the actual Date and Time and change the colume datatyp from int to timestamp. You can add to this time hours , minutes , days and so on to with DATE_ADD.

A example Query from my own Ban-system

SELECT -Query to load the data
Code:
"SELECT `Admin`, `Grund`, DATE_FORMAT(`Datum`, 'Am %%d.%%m.%%Y  um %%T Uhr') AS `BDatum`, DATE_FORMAT (`EntbanDatum`, '%%d.%%m.%%Y um %%H:%%i:%%s Uhr') AS `BEntbanDatum` ,`IP` FROM `bans` WHERE `Name` = '%e' AND  `EntbanDatum` > NOW() LIMIT 0,1;"
INSERT-Query

PHP Code:
"INSERT INTO `bans` (`Name`, `Admin`, `Grund`, `Datum`, `EntbanDatum`, `IP`, `GPCI`) VALUES ('%s', '%s', '%s', NOW(), DATE_ADD(NOW(), INTERVAL %d DAY), '%s', '%s');" 
to check if the Player is now unbanned or not.
Code:
SELECT `EntbanDatum` FROM `bans` WHERE `EntbanDatum` <= NOW();
EntbanDatum = Unbandate.
Datum = Date
Grund = Reason
Reply


Messages In This Thread
MySQL ban system using unix timestamps - by RajatPawar - 22.09.2013, 09:53
Re: MySQL ban system using unix timestamps - by DanishHaq - 22.09.2013, 11:31
Re: MySQL ban system using unix timestamps - by RajatPawar - 22.09.2013, 14:20
Re: MySQL ban system using unix timestamps - by Isolated - 24.09.2013, 21:22
Re: MySQL ban system using unix timestamps - by RajatPawar - 26.09.2013, 06:44
Re: MySQL ban system using unix timestamps - by Isolated - 28.09.2013, 10:31
Re: MySQL ban system using unix timestamps - by IPrototypeI - 28.09.2013, 19:41
Re: MySQL ban system using unix timestamps - by iryston - 09.11.2013, 02:05

Forum Jump:


Users browsing this thread: 1 Guest(s)