Raised This Month: $32 Target: $400
 8% 

php mysql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 01-18-2011 , 05:52   php mysql
Reply With Quote #1

Hey, I've one question.

I've got system that when you send SMS you get privileges for 30 days...

I would like to make such thing like extend your privileges...

So if player already has privileges then it will extend them for 30days...

Right now I've got this:

PHP Code:
$laikas time() + 2592000;
$paring="UPDATE players SET sth=1 expire_date='".$laikas."' WHERE players.id='".$message."')"
So what shall I do to make that the old expire_date + 30days (unix time: 2592000)

Should I check if expire_date is 0 then just add it how it was, and else then expire_date=expire_date+2592000 ???
reinert is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-18-2011 , 06:56   Re: php mysql
Reply With Quote #2

If you're trying to do what i think you're trying to do, you need a SELECT statement to get their old 'expire_date', add 2592000 to that and then do your UPDATE
__________________
minimiller is offline
Send a message via MSN to minimiller
reinert
Veteran Member
Join Date: Feb 2007
Old 01-18-2011 , 07:11   Re: php mysql
Reply With Quote #3

How about this:

Use now() instead of time() which gets time in unix it's more human-able :d

PHP Code:
$aa mysql_query("SELECT expire_time FROM players WHERE players.id='".$message."'); 
PHP Code:
if($aa 0)
{
   
$paring="UPDATE players SET sth=1 expire_date=DATA_ADD(NOW(), INTERVAL 30 DAY) WHERE players.id='".$message."')";
}else{
   
$paring="UPDATE players SET sth=1 expire_date=DATA_ADD($aa, INTERVAL 30 DAY) WHERE players.id='".$message."')";

EDIT: How about this: ??


PHP Code:
$paring="
   UPDATE players
      SET sth = 1,
         expire_date = DATA_ADD(IF(expire_date = 0, NOW(), expire_date), INTERVAL 30 DAY)
   WHERE players.id = '" 
$message "'"
By the way, how to get expire_date correctly ???

this:

DATA_ADD(IF(expire_date = 0,'NOW()', SELECT expire_date FROM players WHERE players.id='".$message."'), INTERVAL 30 DAY)

??

Last edited by reinert; 01-18-2011 at 11:09.
reinert is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-18-2011 , 11:22   Re: php mysql
Reply With Quote #4

You could test to see if it works instead of asking.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-18-2011 , 11:26   Re: php mysql
Reply With Quote #5

I don't have where to test...
reinert is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 01-19-2011 , 09:58   Re: php mysql
Reply With Quote #6

Quote:
Originally Posted by reinert View Post
I don't have where to test...
How about the computer you're now using?
matsi is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-19-2011 , 10:16   Re: php mysql
Reply With Quote #7

Nah, it's not working because my ports cannot be forwarded...
reinert is offline
8088
Veteran Member
Join Date: Jan 2008
Old 01-19-2011 , 10:28   Re: php mysql
Reply With Quote #8

What about http://localhost? If you can't test it, what do you need the code for then?
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-19-2011 , 11:08   Re: php mysql
Reply With Quote #9

XAMPP?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 01-19-2011 , 11:30   Re: php mysql
Reply With Quote #10

Quote:
Originally Posted by reinert View Post
Nah, it's not working because my ports cannot be forwarded...
...
matsi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode