sitesme Posted August 18, 2010 Share Posted August 18, 2010 Hi, I'm getting this error: Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58 The code is: if($Date_Format == 1) #For dd-mm-yyyy { $Date_Output = date("d-m-Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 2) #For dd/mm/yyyy { $Date_Output = date("d/m/Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 3) #For mm-dd-yyyy { $Date_Output = date("m-d-Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 4) #For mm/dd/yyyy { $Date_Output = date("m/d/Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 5) #For Mon Day YYYY { $Date_Output = date("M D Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 6) #For Month Day YYYY { $Date_Output = date("F D Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 7) #For Date"nd" Month YYYY { $Date_Output = date("d\\t\h F Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == #For Month Day YYYY { $Date_Output = date("F d Y",mktime(0,0,0,$Month,$Day,$Year)); } elseif($Date_Format == 9) #For Month Day YYYY { $Date_Output = date("d/m/Y H:i",mktime($DateDispsplittimehr,$DateDispsplittimemin,0,$Month,$Day,$Year)); // Line 58 } return $Date_Output; } else { return NULL; Line 58 says $Date_Output = date("d/m/Y H:i",mktime($DateDispsplittimehr,$DateDispsplittimemin,0,$Month,$Day,$Year)); I really appreciate any help on this. Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2010 Share Posted August 18, 2010 So, did you check what was actually in the 5th parameter? Maybe you are passing it a string instead of a long integer value? Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100776 Share on other sites More sharing options...
sitesme Posted August 18, 2010 Author Share Posted August 18, 2010 Hum... I'm not really a programmer with that knowledge I'm afraid... What I know is that it was working fine on another server so it might be a configuration in PHP or MySQL Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100863 Share on other sites More sharing options...
AbraCadaver Posted August 18, 2010 Share Posted August 18, 2010 Hum... I'm not really a programmer with that knowledge I'm afraid... What I know is that it was working fine on another server so it might be a configuration in PHP or MySQL Any help is appreciated. What does it show if you do this before the if condition? echo $Day; Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100867 Share on other sites More sharing options...
sitesme Posted August 18, 2010 Author Share Posted August 18, 2010 Hi, It shows this: Friday Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58 Wednesday Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58 Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100877 Share on other sites More sharing options...
AbraCadaver Posted August 18, 2010 Share Posted August 18, 2010 Hi, It shows this: Friday Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58 Wednesday Warning: mktime() expects parameter 5 to be long, string given in /home/user/public_html/include/functions.php on line 58 I don't see how it could've worked on another server, maybe error_reporting was turned off so you just didn't get warnings. The day is supposed to be the day number of the month, like today is 18. Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100878 Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2010 Share Posted August 18, 2010 In a way that is kind of funny, because php had this brilliant idea that hiding errors was okay. Your code always contained that error because mktime() NEVER accepted week day names, but the actual error message was being hidden or was filling up your error log on the server. Php still must handle each error in your code, even if the error_reporting or display_errors settings are off. All those settings do is prevent the reporting and display of an error, but php still goes through the error response code every time your script produces an error. So, the question becomes, why is your script putting week day names in as the day of the month and what does your script expect as a result? Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100881 Share on other sites More sharing options...
sitesme Posted August 18, 2010 Author Share Posted August 18, 2010 I understand the matter, and thanks to all for letting me understand the problem better. Obviously I would like to fix the code, how can I do this? Is it in the code or in the database? I'm not a programmer, I'm simply trying to fix the code with my low knowledge. Any help is appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100883 Share on other sites More sharing options...
AbraCadaver Posted August 18, 2010 Share Posted August 18, 2010 I understand the matter, and thanks to all for letting me understand the problem better. Obviously I would like to fix the code, how can I do this? Is it in the code or in the database? I'm not a programmer, I'm simply trying to fix the code with my low knowledge. Any help is appreciated. Thanks. It depends upon where $Month,$Day,$Year are coming from and what date you expect to get. If you want an exact date then you have to provide the day of the month (e.g. 18) from somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100888 Share on other sites More sharing options...
sitesme Posted August 18, 2010 Author Share Posted August 18, 2010 I found in the database two entries with Friday and Wednesday maybe from the beginning when the code was being developed. Deleting these entries, the problem seems fixed. Thanks to all for your help. Quote Link to comment https://forums.phpfreaks.com/topic/211067-warning-mktime-expects-parameter-5-to-be-long-string-given/#findComment-1100889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.