SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: logging stats

  1. #1
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    logging stats

    Hey guys/girls.

    I have tow bits of code here, the top one works fine with Y-m-d date logging, but the other one im trying just to get the month and year.

    PHP Code:
    $time date "Y-m-d" );
    $time2 date "Y-m" );

    // First
    if(@mysql_fetch_array(@mysql_query("SELECT date FROM adsl_counter2 WHERE date='$time'"))) {
    @
    mysql_query("UPDATE adsl_counter2 set count=count+1 WHERE date='$time'");}
    else { 
    mysql_query("INSERT INTO adsl_counter2 SET date=NOW(), count='1'");}

    // Second
    if(@mysql_fetch_array(@mysql_query("SELECT date FROM adsl_counter4 WHERE date='$time2'"))) {
    @
    mysql_query("UPDATE adsl_counter4 set count=count+1 WHERE date='$time2'");}
    else { 
    mysql_query("INSERT INTO adsl_counter4 SET date=NOW(), count='1'");} 
    When the second one is logged into the database it's just 000-00-00 .

    Any help would be great.

  2. #2
    SitePoint Enthusiast Patrick Lucas's Avatar
    Join Date
    Dec 2001
    Location
    Ohio
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dates in MySQL have to be stored YYYY-MM-DD format. If they aren't, it'll put in 0000-00-00 like you're getting.

    So I think you can solve your problem by adding a "-00" to the end of the second date.

    PHP Code:
    $time2 date "Y-m" );
    $time2 .= "-00"
    Not sure if that is the best way to go about it... but as long as the date is in proper format, it should work
    Patrick Lucas

  3. #3
    SitePoint Guru
    Join Date
    Jun 2001
    Location
    Australia
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope that didn't work Patrick.

    Anyone?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •