Warning: mktime() expects parameter 1 to be long

Discussion in 'PHP' started by Divvy, Mar 3, 2009.

  1. #1
    Hi guys,
    Can someone give a little help here?

    Any idea how to fix this ? or what it means....im getting it next to downlod links in phpnuke 7.8.

    line 798 is:
    mktime ("LC_TIME", "$locale");
    Code (markup):
    And full function:
    function categorynewdownloadgraphic($cat) {
        global $prefix, $dbi, $module_name;
        $result_ns = sql_query("select ns_dl_newimage_on, ns_dl_new_one, ns_dl_new_two, ns_dl_new_three from ".$prefix."_ns_downloads_new_pop", $dbi);
        list($ns_dl_newimage_on, $ns_dl_new_one, $ns_dl_new_two, $ns_dl_new_three) = sql_fetch_row($result_ns, $dbi);
        if ($ns_dl_newimage_on == 1) {
       $ns_view_dis = ns_dl_admin_view(2);
        $newresult = sql_query("select date from ".$prefix."_downloads_downloads where cid='$cat' $ns_view_dis order by date desc limit 1", $dbi);
        list($time)=sql_fetch_row($newresult, $dbi);
        echo " ";
        mktime ("LC_TIME", "$locale");
        ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
        $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
        $datetime = ucfirst($datetime);         
        $startdate = time();
        $count = 0;
        while ($count <= $ns_dl_new_three) {
       $daysold = date(_NSDAY1, $startdate);
            if ("$daysold" == "$datetime") {
               if ($count <= $ns_dl_new_one) {
          echo "<img src=\"modules/$module_name/images/new_1.gif\" alt=\""._DCATNEWTODAY."\">";
           }
                if ($count <= $ns_dl_new_two && $count > $ns_dl_new_one) {
          echo "<img src=\"modules/$module_name/images/new_3.gif\" alt=\""._DCATLAST3DAYS."\">";
           }
                if ($count <= $ns_dl_new_three && $count > $ns_dl_new_two) {
          echo "<img src=\"modules/$module_name/images/new_7.gif\" alt=\""._DCATTHISWEEK."\">";
           }
       }
            $count++;
            $startdate = (time()-(86400 * $count));
        }
      }
    }
    
    Code (markup):
    Thank you :)
     
    Divvy, Mar 3, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    well mktime wants next things
    int mktime ([ int $hour= date("H") [, int $minute= date("i") [, int $second= date("s") [, int $month= date("n") [, int $day= date("j") [, int $year= date("Y") [, int $is_dst= -1 ]]]]]]] )
    where int means integer (number)

    source http://php.net/mktime
     
    crivion, Mar 3, 2009 IP
  3. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Hi crivion,
    thank you so much for your reply.

    But my php knowledge is very very low.
    Can you tell me what I need to modify in my code in order to fix the problem? :)
     
    Divvy, Mar 3, 2009 IP
  4. qualityfirst

    qualityfirst Peon

    Messages:
    147
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    0
    #4
    mktime is used to calculate a timestamp relative to what the current one is.

    It accepts data in the following format:

    mktime(hour,minute,second,month,day,year,dst)

    So in the hour section you would enter 3 hours if you wanted to timestamp of 3 hours ahead of now. Same for minutes, month, seconds, day, year. DST is set to 1 if you want Daylight Savings Time calculated and 0 if you don't.

    You are trying to pass LC_TIME in the first place, and that's not something PHP will accept as a value for hours.
     
    qualityfirst, Mar 3, 2009 IP
  5. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #5
    what exactly is the time you need to pass there? need to help you
     
    crivion, Mar 3, 2009 IP
  6. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #6
    It looks like someone accidently used mktime when they meant to use setlocale, or used the setlocale arguments when they meant to use mktimes.

    If it's meant to be the setlocale function, remove the quotes from around "LC_TIME".
    LC_TIME is a constant defined for the setlocale function.

    setlocale (LC_TIME, "$locale");
    Code (markup):
     
    joebert, Mar 3, 2009 IP
  7. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #7
    crivion, sorry my friend, but I really dont know what to answer you... damn.... ;(
    This was the code that came with the cms phpnuke.
     
    Divvy, Mar 3, 2009 IP
  8. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #8
    Thank you so much :D
    The errors disappeared! Problem solved :)
    You are the MAN!
     
    Divvy, Mar 3, 2009 IP
  9. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #9
    Don't thank me yet, just because those errors vanished doesn't mean it was fixed.

    Does everything that works with dates still work as expected ?
     
    joebert, Mar 3, 2009 IP
  10. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #10
    Everything is working 100% so far :)
     
    Divvy, Mar 3, 2009 IP
  11. tezza42

    tezza42 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Check out this site to remove the mktime warning:

    www.4u3.biz

    Sorry! Can't hyperlink the site as I don't have enough posts.
     
    tezza42, Dec 21, 2009 IP