Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
selectric
Regular
Regular


Joined: Aug 06, 2008
Posts: 65

PostPosted: Mon Apr 13, 2009 1:14 pm Reply with quote

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!
 
View user's profile Send private message
bluerace
Regular
Regular


Joined: Apr 04, 2009
Posts: 85
Location: Behind you

PostPosted: Mon Apr 13, 2009 2:21 pm Reply with quote

read mktime depreciation described in the following url:
Only registered users can see links on this board! Get registered or login!

_________________
Make stupid PHP-NUKE Smart, that's my favorite chore in Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
selectric
PostPosted: Mon Apr 13, 2009 2:30 pm Reply with quote

bluerace wrote:
read mktime depreciation described in the following url:
Only registered users can see links on this board! Get registered or login!


Hey thanks alot for writing up a post about it!
 
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6792
Location: Ha Noi, Viet Nam

PostPosted: Fri May 08, 2009 9:47 am Reply with quote

Says module is not active at that link
 
View user's profile Send private message Send e-mail
bluerace
PostPosted: Fri May 08, 2009 11:32 am Reply with quote

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:
Only registered users can see links on this board! Get registered or login!

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
PostPosted: Fri May 08, 2009 12:28 pm Reply with quote

Let me write more or less longer description about fundamental solutions to the deprecation and casting of mktime() function as follows:
Only registered users can see links on this board! Get registered or login!
 
duck
Involved
Involved


Joined: Jul 03, 2006
Posts: 273

PostPosted: Fri May 08, 2009 2:03 pm Reply with quote

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.
 
View user's profile Send private message
Guardian2003
PostPosted: Fri May 08, 2009 2:41 pm Reply with quote

$yourvar = mktime((int)$var1,(int)$var2,(int)$var3,(int)$var4,(int)$var5,(int)$var6);
 
bluerace
PostPosted: Fri May 08, 2009 3:35 pm Reply with quote

Actually, you don't have to cast when you use different mysql query schemes.
Let me write a post for this.
 
duck
PostPosted: Fri May 08, 2009 4:02 pm Reply with quote

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
Involved


Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Fri May 08, 2009 4:10 pm Reply with quote

Only registered users can see links on this board! Get registered or login! for references.

I know i've fixed my errors looking on google . But it was last year Sad
 
View user's profile Send private message Visit poster's website MSN Messenger
Guardian2003
PostPosted: Fri May 08, 2009 11:48 pm Reply with quote

@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 Sad
 
eldorado
PostPosted: Sun May 10, 2009 2:32 am Reply with quote

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 Sad

oh yeah me too , though I wasn't horrified Very Happy
 
nextgen
Worker
Worker


Joined: Sep 28, 2006
Posts: 226
Location: Maryland

PostPosted: Tue May 12, 2009 7:15 pm Reply with quote

Adding the edits to the mainfile has cleared all of my errors. Great solution friends.

_________________
alterednuke.com Your source for Ravennuke themes. 
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Guardian2003
PostPosted: Wed May 13, 2009 1:05 am Reply with quote

.. just remember that it's just a band aid.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©