| Author |
Message |
selectric Regular


Joined: Aug 06, 2008 Posts: 65
|
Posted:
Mon Apr 13, 2009 1:14 pm |
|
Hello! Thanks for your time in reading this post...
I am suddenly getting getting the following error code log:
| Code: |
[Sun Apr 12 14:04:24 2009] [error] [client *********] PHP Warning: mktime() expects parameter 1 to be long, string given in /html/modules/Homepage/index.php on line 266
|
Here is the time code I am using:
| Code: | $time = $myrow['time'];
formatTimestamp($time);
setlocale(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, $datetime2);
$datetime2 = strftime(""._DATESTRING2."", mktime($datetime2[4],$datetime2[5],$datetime2[6],$datetime2[2],$datetime2[3],$datetime2[1]));
$datetime2 = ucfirst($datetime2); |
Line 266 is:
| Code: | | $datetime2 = strftime(""._DATESTRING2."", mktime($datetime2[4],$datetime2[5],$datetime2[6],$datetime2[2],$datetime2[3],$datetime2[1])); |
Does anyone know what the problem is? I have been using this code for years now.
Thanks! |
|
|
|
 |
bluerace Regular


Joined: Apr 04, 2009 Posts: 85 Location: Behind you
|
Posted:
Mon Apr 13, 2009 2:21 pm |
|
read mktime depreciation described in the following url:
|
|
|
|
 |
selectric Regular


Joined: Aug 06, 2008 Posts: 65
|
Posted:
Mon Apr 13, 2009 2:30 pm |
|
| bluerace wrote: | read mktime depreciation described in the following url:
|
Hey thanks alot for writing up a post about it! |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri May 08, 2009 9:47 am |
|
Says module is not active at that link |
|
|
|
 |
bluerace Regular


Joined: Apr 04, 2009 Posts: 85 Location: Behind you
|
Posted:
Fri May 08, 2009 11:32 am |
|
Sorry, Guardian2003.
The module does not work becaus the whole BB board was replaced with final phpBB3ToNuke 3.0.4 RC1.
Simple click the following:
The whole phpBB3 system was slightly changed.
Oh, by the way, mktime() program is strongly related to 'date' field format in mysql. About this, I will post ONE SUGGESTION to outroot this problem. |
|
|
|
 |
bluerace Regular


Joined: Apr 04, 2009 Posts: 85 Location: Behind you
|
Posted:
Fri May 08, 2009 12:28 pm |
|
Let me write more or less longer description about fundamental solutions to the deprecation and casting of mktime() function as follows:
|
|
|
|
 |
duck Involved


Joined: Jul 03, 2006 Posts: 267
|
Posted:
Fri May 08, 2009 2:03 pm |
|
While your suggestion is on the right mark bluerace of needing to cast vars to int to work I would suggest something like the following might be easier.
Not 100% sure this won't raise some other issue but I don't think so but anyway you could include the following function into mainfile.php and then just do a search replace of mktime( replace with mktime2( in all files.
| Code: |
function mktime2($var1=0, $var2=0, $var3=0, $var4=0, $var5=0, $var6=0, $var7=-1){
$var1 = (int)$var1;
$var2 = (int)$var2;
$var3 = (int)$var3;
$var4 = (int)$var4;
$var5 = (int)$var5;
$var6 = (int)$var6;
$var7 = (int)$var7;
$returnvar = mktime($var1, $var2, $var3, $var4, $var5, $var6, $var7);
return $returnvar;
} |
This might be easier than hunting down all the different variables to cast to int. |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri May 08, 2009 2:41 pm |
|
$yourvar = mktime((int)$var1,(int)$var2,(int)$var3,(int)$var4,(int)$var5,(int)$var6); |
|
|
|
 |
bluerace Regular


Joined: Apr 04, 2009 Posts: 85 Location: Behind you
|
Posted:
Fri May 08, 2009 3:35 pm |
|
Actually, you don't have to cast when you use different mysql query schemes.
Let me write a post for this. |
|
|
|
 |
duck Involved


Joined: Jul 03, 2006 Posts: 267
|
Posted:
Fri May 08, 2009 4:02 pm |
|
| Guardian2003 wrote: | | $yourvar = mktime((int)$var1,(int)$var2,(int)$var3,(int)$var4,(int)$var5,(int)$var6); |
The reason I suggested another function inside mainfile.php is cause if you've recently upgrade then many files throughout your site may be using mktime and failing.
it's ok to change one set of vars to the call when you know where the problem is but when you wanna look through 1000's of files for mktime calls with different variable names that could be a real PITA but a search and replace of mktime( to mktime2( could be done on those same 1000 files in seconds. then all works well. |
|
|
|
 |
eldorado Involved


Joined: Sep 10, 2008 Posts: 414 Location: France,Translator
|
Posted:
Fri May 08, 2009 4:10 pm |
|
for references.
I know i've fixed my errors looking on google . But it was last year  |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Fri May 08, 2009 11:48 pm |
|
@duck I agree that it would be useful to have such a function, especially for those that are fixing old code and don't have the time to go through thousands of files or who don't use an IDE when developing.
I was actually quite horrified when googling this error to find a lot of sites indexed in google showing this error on site pages and revealing server paths  |
|
|
|
 |
eldorado Involved


Joined: Sep 10, 2008 Posts: 414 Location: France,Translator
|
Posted:
Sun May 10, 2009 2:32 am |
|
| Guardian2003 wrote: | @duck I agree that it would be useful to have such a function, especially for those that are fixing old code and don't have the time to go through thousands of files or who don't use an IDE when developing.
I was actually quite horrified when googling this error to find a lot of sites indexed in google showing this error on site pages and revealing server paths |
oh yeah me too , though I wasn't horrified  |
|
|
|
 |
nextgen Worker


Joined: Sep 28, 2006 Posts: 135 Location: Maryland
|
Posted:
Tue May 12, 2009 7:15 pm |
|
Adding the edits to the mainfile has cleared all of my errors. Great solution friends. |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
|
Posted:
Wed May 13, 2009 1:05 am |
|
.. just remember that it's just a band aid. |
|
|
|
 |
|
|
|
|