View Single Post
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 07-21-2011 , 11:04   Re: How to get date from database ?
Reply With Quote #8

Quote:
Originally Posted by BFBombi View Post
Okey, i tryed it but where is my error ?
your logic is borked in several places:

PHP Code:
new BaseDate;
CheckDate(clientBaseDate); 
You never set BaseDate, so it is always 0, therefore your print output in CheckDate() is always '...(in unixtime): 0'.
But you don't want to print in there to begin with, because you are using a threaded query, which means you won't have the results ready after calling CheckDate, but only after T_CheckDate has been called. Only then you could use your results e.g. to print them.

PHP Code:
Format(querysizeof(query), "SELECT last_date FROM users WHERE last_date = '%i'"BaseDate);
SQL_TQuery(DatabaseT_CheckDatequeryclient); 
Again, BaseDate is not set and you select the attribute you are querying against in the first place, so your sql query could be read as: "Select 0". Well almost. You will get a number of rows all with the result 0, if there are any rows in your table with last_date = 0.
I also thought you wanted to check how many days a certain user has left, so your query should rather be sth like this:
"select last_date FROM users WHERE steamid = 'STEAM_0:1:12314'".
Furthermore you'll never do anything with the result you get from the database (which you should do in T_CheckDate()).

As a principal hint: Don't try to do everything at once, but start slow and grow your code. So you first want to have the correct SQL query, use phpMyAdmin or whatever you are comfortable with to create and test your query. If you are getting the results you want (steamid + last_date), proceed to your plugin and use non-threaded queries. If those work, rewrite your code to use threaded queries.
You are currently trying to do all at the same time, which is bound to fail if you are new to all of them.
__________________
einmal mit profis arbeiten. einmal.

Last edited by Thrawn2; 07-21-2011 at 11:08.
Thrawn2 is offline