variable - variable wont work

k i am trying to minus a varible from another variable and its giving me an error. this is what im doing:

$daysinclan = $today-$dayjoined;

and in the today variable i did:
$today = date("Ymd"); and that is 20031109 and
$dayjoined is the same thing but wen the person was added

what should i do?

Comments

  • aha, you should not use date this way.

    how about using the unix timestamp function time() (see php.net) it returns the number of seconds since feb or jan 1970.

    $dayjoined = time(); and put it in the DB
    for today.. or THIS moment $today = time();

    $secondsinclan would be time() - $dayjoined;

    you can calculate for yourself how many seconds a day has. use round() to round the number because we don't use .4345353 day or something like that. you also should round it DOWN. see php.net again. (noticed it's functional input box at the top?? that the only thing i use php.net for.)

    will this help you??

    oh, i forgot, you can use the date function WITH the unix timestamp time(). you can produce a readable date out of a timestamp by doing $date = date("yourformat",time());



    : k i am trying to minus a varible from another variable and its giving me an error. this is what im doing:
    :
    : $daysinclan = $today-$dayjoined;
    :
    : and in the today variable i did:
    : $today = date("Ymd"); and that is 20031109 and
    : $dayjoined is the same thing but wen the person was added
    :
    : what should i do?
    :

    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    url--> http://mark.space.servehttp.com

  • ah well i alrdy made it have the date() thing throught the entire thign so i found this:

    mysql_connect("$dbhost","$dbuser","$dbpass");
    mysql_select_db("$dbname");
    $query = "SELECT TO_DAYS($today)-TO_DAYS(datejoined) FROM $clan_members WHERE Name = '$user'";
    $result = mysql_query($query);
    $daysinclan = mysql_fetch_array($result);

    will that work?


    : aha, you should not use date this way.
    :
    : how about using the unix timestamp function time() (see php.net) it returns the number of seconds since feb or jan 1970.
    :
    : $dayjoined = time(); and put it in the DB
    : for today.. or THIS moment $today = time();
    :
    : $secondsinclan would be time() - $dayjoined;
    :
    : you can calculate for yourself how many seconds a day has. use round() to round the number because we don't use .4345353 day or something like that. you also should round it DOWN. see php.net again. (noticed it's functional input box at the top?? that the only thing i use php.net for.)
    :
    : will this help you??
    :
    : oh, i forgot, you can use the date function WITH the unix timestamp time(). you can produce a readable date out of a timestamp by doing $date = date("yourformat",time());
    :
    :
    :
    : : k i am trying to minus a varible from another variable and its giving me an error. this is what im doing:
    : :
    : : $daysinclan = $today-$dayjoined;
    : :
    : : and in the today variable i did:
    : : $today = date("Ymd"); and that is 20031109 and
    : : $dayjoined is the same thing but wen the person was added
    : :
    : : what should i do?
    : :
    :
    : [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    : url--> http://mark.space.servehttp.com
    :
    :

  • : $query = "SELECT TO_DAYS($today)-TO_DAYS(datejoined) FROM
    : $clan_members WHERE Name = '$user'";
    May do, you could also try:-

    $query = "SELECT $today - INTERVAL datejoined DAY FROM
    $clan_members WHERE Name = '$user'";

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • i dont want to start another thing because ive created a lot alrdy and this is just a quick question

    how can i fix this?

    mysql_connect("$dbhost","$dbuser","$dbpass");
    mysql_select_db("$dbname");
    $query = "UPDATE $clan_members SET status = 'Offline' WHERE exptime >= '$time' AND expday = '$today'";
    $result = mysql_query($query)
    or die("Couldn't Execute Query");




    : : $query = "SELECT TO_DAYS($today)-TO_DAYS(datejoined) FROM
    : : $clan_members WHERE Name = '$user'";
    : May do, you could also try:-
    :
    : $query = "SELECT $today - INTERVAL datejoined DAY FROM
    : $clan_members WHERE Name = '$user'";
    :
    : Jonathan
    :
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

  • : i dont want to start another thing because ive created a lot alrdy and this is just a quick question
    :
    : how can i fix this?
    :
    : mysql_connect("$dbhost","$dbuser","$dbpass");
    : mysql_select_db("$dbname");
    : $query = "UPDATE $clan_members SET status = 'Offline' WHERE exptime >= '$time' AND expday = '$today'";
    : $result = mysql_query($query)
    : or die("Couldn't Execute Query");
    :
    That in theory shoudl work, though of course it working depends on:-

    1) The types of the fields exptime and expday
    2) The values = $time and $today

    Without those, I can't help much.

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • $time is $time = time();
    $today is $today = date("Ymd",time());

    i made them both varchar in the mysql db do i have to change them to something else?




    : : i dont want to start another thing because ive created a lot alrdy and this is just a quick question
    : :
    : : how can i fix this?
    : :
    : : mysql_connect("$dbhost","$dbuser","$dbpass");
    : : mysql_select_db("$dbname");
    : : $query = "UPDATE $clan_members SET status = 'Offline' WHERE exptime >= '$time' AND expday = '$today'";
    : : $result = mysql_query($query)
    : : or die("Couldn't Execute Query");
    : :
    : That in theory shoudl work, though of course it working depends on:-
    :
    : 1) The types of the fields exptime and expday
    : 2) The values = $time and $today
    :
    : Without those, I can't help much.
    :
    : Jonathan
    :
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

  • : i made them both varchar in the mysql db do i have to change them to
    : something else?
    If you want to use MySQL's inbuilt data handling functions you most probably want to have them as datetime type fields.

    Jonathan


    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories