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
testy1
Involved
Involved



Joined: Apr 06, 2008
Posts: 484

PostPosted: Thu Jul 31, 2008 4:41 pm Reply with quote

Im working on a module and i keep getting the following php notice.

Code:


Warning: mktime() expects parameter 6 to be long
Notice: Undefined index: 1
Notice: Undefined index: 2


the code is as follows

Code:


$time = strftime("%F", mktime($time[4], $time[5], $time[6], $time[2],$ time[3], $time[1]));

   $date_array = explode("-", $time);
   

   $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);

     $formatted_date = date("F j, Y", $timestamp);



so i thought i would check that date_array exists before proceeding

Code:


$time = strftime("%F", mktime($time[4], $time[5], $time[6], $time[2],$ time[3], $time[1]));
     
       
   $date_array = explode("-", $time);
     
   if (!empty($date_array)) {
   $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
       }

     $formatted_date = date("F j, Y", $timestamp);


but the warning still exists, i have a feeling its php5 related as i dont remember ever having this issue before.

Anyone got any ideas on this.
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Thu Jul 31, 2008 6:51 pm Reply with quote

Quote:
$time = strftime("%F", mktime($time[4], $time[5], $time[6], $time[2],$ time[3], $time[1]));


I'm unable to test this because that code is referencing a $time array but you have not included the code that creates the $time array. Please supply all the needed code.

But, in general, the error seems to be saying that $time[1] is not in a format the strftime() is expecting.
 
View user's profile Send private message
testy1







PostPosted: Thu Jul 31, 2008 7:42 pm Reply with quote

argh ok forgot about that lol its pulling from the database

Code:


while(list($rating, $timestamp) = $db->sql_fetchrow($result)) {

       $comments = stripslashes($comments);

       ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $timestamp, $time);
 
Raven







PostPosted: Thu Jul 31, 2008 8:42 pm Reply with quote

Unfortunately that still won't help. It's the data that's the issue. The function is receiving unexpected "type" data. An example would be expecting a date and receiving a string. Try listing out all the timestamps and you will probably see the invaid value somewhere.
 
testy1







PostPosted: Thu Jul 31, 2008 11:38 pm Reply with quote

well using var dump on $time before this code

Code:


$time= strftime("%F",mktime($time[4],$time[5],$time[6],$time[2],$time[3],$time[1]));


i get

Code:


string(4) "2008"

string(2) "08"

string(2) "01"

string(2) "08"

string(2) "27"

string(2) "03"


if i run var dump after the first piece of code i get

Code:


NULL

NULL

NULL

NULL

NULL

NULL


so it wouls seem this is the problem

Code:


$time= strftime("%F",mktime($time[4],$time[5],$time[6],$time[2],$time[3],$time[1]));


can anyone see anything wrong with it
 
Raven







PostPosted: Fri Aug 01, 2008 12:07 am Reply with quote

As I said, the function is receiving unexpected "type" data
[ Only registered users can see links on this board! Get registered or login! ]

Your $time array is invalid.
 
testy1







PostPosted: Fri Aug 01, 2008 12:38 am Reply with quote

sorry ive always had trouble with mktime Sad

before it goes through this

Code:


$time= strftime("%F",mktime($time[4],$time[5],$time[6],$time[2],$time[3],$time[1]));


its fine but after it outputs.

Code:


bool(false)


im still thinking this is php5 related.
 
Raven







PostPosted: Fri Aug 01, 2008 12:57 am Reply with quote

What are the values for each of these? They have to form a valid time stamp.

$time[4]
$time[5]
$time[6]
$time[2]
$time[3]
$time[1]
 
testy1







PostPosted: Fri Aug 01, 2008 1:11 am Reply with quote

in the same order as you suggested

Code:


string(2) "08"

string(2) "27"

string(2) "03"

string(2) "08"

string(2) "01"

string(4) "2008"
 
Raven







PostPosted: Fri Aug 01, 2008 10:51 am Reply with quote

Edited out - I misread your previous post.


Last edited by Raven on Fri Aug 01, 2008 9:38 pm; edited 1 time in total 
testy1







PostPosted: Fri Aug 01, 2008 6:07 pm Reply with quote

lol yer but which ones they all seem to be there to me?

i noticeed that since php 5.1 they introduced $is_dst could that be it
 
Raven







PostPosted: Fri Aug 01, 2008 9:41 pm Reply with quote

Google for Warning: mktime() expects parameter 6 to be long and read the issues. It could just be you're using a buggy PHP5 release.
 
selectric
Regular
Regular



Joined: Aug 06, 2008
Posts: 65

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

Im working something like this too: [ Only registered users can see links on this board! Get registered or login! ]
 
View user's profile Send private message
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 ©