[PHP] mktime() werkt niet welke alternatief?

Gestart doorChristum9 reacties66 weergaven

10 berichten · pagina 1 van 1

Christum

Lid · Topicstarter

Berichten
921
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Beste one2xsers,

Ik ben al een tijdje niet erg actief geweest maar heb een vraag waar ik zelf helemaal niet meer uit kom, ik heb een script gemaakt alleen gebruikt de hoster php 5.1 en daar werkt blijkbaar de mktime() niet.
Ik heb op php.net gekeken voor een eventueel alternatief alleen daar geven ze aan de time() te gebruiken die al eerder voorkomt in het script, ik heb dat geprobeert maar kom er alsnog niet uit.

Hierbij een stukje van het script:

// Calculate the amount of club Days left
function HCDaysLeft($my_id){

    // Query for the info we need to calculate
    $sql = mysql_query("SELECT months_left,date_monthstarted FROM leden_clublid WHERE member_id = ".$my_id." LIMIT 1") or die(mysql_error());
    $tmp = mysql_fetch_assoc($sql);
    $valid = mysql_num_rows($sql);

    if($valid > 0){

        // Collect the variables we need from the query result
        $months_left = $tmp[months_left];
        $month_started = $tmp[date_monthstarted];

        // We take 31 days for every month left, assuming each month has 31 days
        $days_left = $months_left * 31;

        // Split up the day/month/year so we can use it with mktime
        $tmp = explode("-", $month_started);
        $day = $tmp[0];
        $month = $tmp[1];
        $year = $tmp[2];

        // First of all make the dates we want to compare, do some math
        $then = mktime(0, 0, 0, $month, $day, $year, 0);
        $now = time();
        $difference = $now - $then;

        // If this month expired already
        if ($difference < 0){
            $difference = 0;
        }

        // Now do some math
        $days_expired = floor($difference/60/60/24);

        // update de maanden die je gehad hebt.
        $aantal_maanden_gehad =  floor($days_expired/31);
        mysql_query("UPDATE leden_clublid SET months_expired = ".$aantal_maanden_gehad." WHERE member_id = ".$my_id." LIMIT 1") or die(mysql_error());

        // $days_expired stands for the days we already wasted in this month
        // 31 days for each month added together, minus the days weve wasted in the current month, is the amount of days we have left, totally
        $days_left = $days_left - $days_expired;
        return $days_left;
        
    } else {
        return 0;
    }
}


Hopelijk kan iemand hier iets mee, alvast bedankt.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Misschien handig om eerst even de fouten die je krijgt hier neer te zetten. mktime() hoort namelijk wel gewoon te werken in PHP 5.1, het zat zelfs al in PHP 4
0
Christum

Lid · Topicstarter

Berichten
921
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Luukvdo schreef:
Misschien handig om eerst even de fouten die je krijgt hier neer te zetten. mktime() hoort namelijk wel gewoon te werken in PHP 5.1, het zat zelfs al in PHP 4
Oeps idd, dat lijkt mij ook handig yummieHier de foutmeldingen:

Deprecated: mktime() [function.mktime]: The is_dst parameter is deprecated in /public/sites/www.website.nl/class/iframe.class.php on line 531
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Ik tel 7 paramaters in mktime() bij jouw. De laatste is: is_dst

Laat die nou depricated/afgekeurd zijn, dus die haal je weg.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Oftewel:

$then = mktime(0, 0, 0, $month, $day, $year, 0);


Vervangen door:

$then = mktime(0, 0, 0, $month, $day, $year);
0
Christum

Lid · Topicstarter

Berichten
921
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aarclay schreef:
Ik tel 7 paramaters in mktime() bij jouw. De laatste is: is_dst

Laat die nou depricated/afgekeurd zijn, dus die haal je weg.
Het is idd gelukt, teminste hij geeft de aantal dagen aan die hij zou moeten weergeven volgens mijn berekeningen
Luukvdo schreef:
Oftewel:

$then = mktime(0, 0, 0, $month, $day, $year, 0);
Vervangen door:

$then = mktime(0, 0, 0, $month, $day, $year);


Zover was ik idd ook gekomen, in ieder geval bedankt voor jullie hulp wink
0
Berichten
6.485
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zet volgende keer ff tags om je code heen. Dan krijgen wij mooie kleurtjes te zien smile
0
Christum

Lid · Topicstarter

Berichten
921
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rogier schreef:
Zet volgende keer ff tags om je code heen. Dan krijgen wij mooie kleurtjes te zien smile
Lijkt me idd ook handig, ik ben al tijdje niet meer hier geweest dus dacht dat het zou zou werken bloos
Maar nu ik toch een reactie plaats, ik heb nog een probleem gevonden dit keer met een eregi functie:
[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://habbo.nl/community/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$start[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<div id="habbos-online"><div class="rounded"><span>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$end[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]</span></div></div>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$read[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$start(.*)$end"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$read[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
?>


En ik krijg de volgende error:
Deprecated: Function eregi() is deprecated in /public/sites/www.habbofliet.nl/includes/leden/tab3.php on line 70
Ik heb al voor alternative functies gezocht op internet, maar helaas werkt ruim 90% niet sadley
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lasertools schreef:
Eerdere citaten tonen
Rogier schreef:
Zet volgende keer ff tags om je code heen. Dan krijgen wij mooie kleurtjes te zien smile
Lijkt me idd ook handig, ik ben al tijdje niet meer hier geweest dus dacht dat het zou zou werken bloos
Maar nu ik toch een reactie plaats, ik heb nog een probleem gevonden dit keer met een eregi functie:

[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://habbo.nl/community/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$start[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<div id="habbos-online"><div class="rounded"><span>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$end[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]</span></div></div>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$read[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$start(.*)$end"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$read[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
?>


En ik krijg de volgende error:
Deprecated: Function eregi() is deprecated in /public/sites/www.habbofliet.nl/includes/leden/tab3.php on line 70
Ik heb al voor alternative functies gezocht op internet, maar helaas werkt ruim 90% niet sadley
http://www.php.net/eregi
Probeer met explode wink
toevoeging op 12 mei 2012, 16:03:25:

[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://habbo.nl/community/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$start[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<div id="habbos-online"><div class="rounded"><span>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$end[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]</span></div></div>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$read[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$start[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$read[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$output[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$end[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]];[/COLOR]
?>


Snel getypt yummie
0
Christum

Lid · Topicstarter

Berichten
921
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maartenl schreef:
Eerdere citaten tonen
Lasertools schreef:
Eerdere citaten tonen
Rogier schreef:
Zet volgende keer ff tags om je code heen. Dan krijgen wij mooie kleurtjes te zien smile
Lijkt me idd ook handig, ik ben al tijdje niet meer hier geweest dus dacht dat het zou zou werken bloos
Maar nu ik toch een reactie plaats, ik heb nog een probleem gevonden dit keer met een eregi functie:

[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://habbo.nl/community/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$start[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<div id="habbos-online"><div class="rounded"><span>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$end[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]</span></div></div>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$read[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$start(.*)$end"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$read[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
?>


En ik krijg de volgende error:
Deprecated: Function eregi() is deprecated in /public/sites/www.habbofliet.nl/includes/leden/tab3.php on line 70
Ik heb al voor alternative functies gezocht op internet, maar helaas werkt ruim 90% niet sadley
http://www.php.net/eregi
Probeer met explode wink
toevoeging op 12 mei 2012, 16:03:25:

[COLOR= #0000BB]<?php
$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"http://habbo.nl/community/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$start[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]<div id="habbos-online"><div class="rounded"><span>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$end[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]</span></div></div>[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$read[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$data[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$start[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$read[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$output[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/explode"]explode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$end[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$data[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$output[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]];[/COLOR]
?>


Snel getypt yummie
Jup dit werkt, nu ga ik eens kijken of het deel achter de counter weg te krijgen is, aangezien ik die informatie niet nodig heb smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren