Error : mktime() expects parameter 6 to be long, Help me to solve

Discussion in 'PHP' started by pradimani, Jul 12, 2010.

  1. #1
    Hey am getting an error like this

    Warning: mktime() expects parameter 6 to be long, string given in /home/bizdirec/public_html/includes/functions.php on line 320

    So what could be wrong ?

    View attachment 1.txt

    $date_day = date ( "d" );
    $date_month = date ( "m" );
    $date_year = date ( "Y" );

    list ( $on_year, $on_month, $on_day ) = split ( '[/.-]', $date );

    $first_date = mktime ( 0,0,0,$on_month,$on_day,$on_year );
    $second_date = mktime ( 0,0,0,$date_month,$date_day,$date_year );

    if ( $second_date > $first_date )

    Plz help me to resolve the problem.
     
    pradimani, Jul 12, 2010 IP
  2. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #2
    The clue is in the error message; but its a bit of a red herring. If you know the data is just the wrong type, you can just cast it like so;

    $first_date = mktime ( 0,0,0,$on_month, $on_day, (int) $on_year );
    PHP:
    However, taking a look at your code

    list ( $on_year, $on_month, $on_day ) = split ( '[/.-]', $date );
    PHP:
    It would appear $date is empty/not defined so the list of variables will contain nothing. (casting it as an int would still work, but it would be forced to zero).
     
    lukeg32, Jul 13, 2010 IP
  3. pradimani

    pradimani Active Member

    Messages:
    306
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks Mr lukeg32

    The error message is not showing now. But still i have one doubt.

    Classified listings are supposed to expire after the defined period. Will it work ?
     
    pradimani, Jul 13, 2010 IP
  4. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Yah - if the current time is more than the time you are processing, looks like it will work fine.

    It might be just as simple - if its stored in mysql database - to let the database sort it;

    SELECT rowid FROM your_table WHERE now() > your_date_field;
    
    [... process expired classifieds ...]
    Code (markup):
     
    lukeg32, Jul 13, 2010 IP