1
preachur
Not exactly an xoops module, but......
  • 2008/6/12 1:05

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


I have an XOOPS community site and an installation of php pro bid auction software running on the same database. In other words, everyone who joins the auction site is also automatically a member of the community site. My host upgraded php4 to php5 recently, and now whenever anyone registers there is this error:

"Warning: mktime() expects parameter 1 to be long, string given in config/datecalc.php on line 64"

Registration still goes through, but the error worries me, and the site users have complained about it..

This is line 64:

$daysleft=mktime($arrTime[0],$arrTime[1],$arrTime[2],$arrDate[1],$arrDate[2],$arrDate[0]);

Now, I have looked all over the internet for an answer. The php pro bid people tell me that I can upgrade to their new software to fix it, but I won't be able to keep the XOOPS site linked in anymore if I do that. I tried it on a test site and their new authentication system isn't compatible. At least not to a non-expert like me.

So, I bring this problem to the only other place I know. To the expert developers and geniuses at Xoops.org.

Anyone know what I can do to fix this?

Mark
Magick can never be restrained, but when freely given is thrice regained!

2
preachur
Re: Not exactly an xoops module, but......
  • 2008/6/12 1:40

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


Here is the whole code section. I THINK it might be the date format causing this problem, but I am not sure. I am assuming it is the function that checks to make sure a user is 18 years old, but I could be wrong. I tried replacing all insances of "mktime" with "time", but then it thinks everyone is too young to join no matter what birthday they enter. I also tried "gmmktime" and the error returned.

function daysleft($date,$format) {

### this function will return the number of seconds between 2 dates!!
$today=date("Y-m-d H:i:s");
$split_datenow=explode (" ",$today);
$date_now=explode ("-",$split_datenow[0]);
list ($nyear,$nmonth,$nday)=$date_now;
$time_now=explode (":",$split_datenow[1]);
list ($nhour,$nmin,$nsec)=$time_now;
$datenow=mktime($nhour,$nmin,$nsec,$nmonth,$nday,$nyear);

$arrDateTime = explode(" ", $date);
$arrDate = explode("-", $arrDateTime[0]);
$arrTime = explode(":", $arrDateTime[1]);
$daysleft=mktime($arrTime[0],$arrTime[1],$arrTime[2],$arrDate[1],$arrDate[2],$arrDate[0]);

$daycount=intval($daysleft-$datenow);


return $daycount;
}
Magick can never be restrained, but when freely given is thrice regained!

3
Anonymous
Re: Not exactly an xoops module, but......
  • 2008/6/12 1:44

  • Anonymous

  • Posts: 0

  • Since:


Quote:
mktime function accepts all parameters as integer based ones, if you try to pass a non integer/number type value then it will show this warning. Make sure that you are passing all integer/number based values.



http://www.dynamicdrive.com/forums/showthread.php?p=146422

I think you need to reset date field in one of this script MySQL tables.

4
preachur
Re: Not exactly an xoops module, but......
  • 2008/6/12 1:57

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


I tried changing it so that people enter the full birthdate instead of just the year, but it still gives the same error.
Magick can never be restrained, but when freely given is thrice regained!

5
banmelater
Re: Not exactly an xoops module, but......
  • 2008/6/12 6:59

  • banmelater

  • Just popping in

  • Posts: 1

  • Since: 2008/6/12


empty "" can cause this error, try using the 0's

ex:
$arrDateTime = explode("0", $date);

6
trabis
Re: Not exactly an xoops module, but......
  • 2008/6/12 13:00

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Please show us the code that calls this function:

function daysleft($date,$format)

7
preachur
Re: Not exactly an xoops module, but......
  • 2008/6/13 0:52

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


$birthYear=$_POST['year'];
if ($_POST['year']<1970) $birthYear = 1971;
if ($_POST['year']<=1910) $birthYear = 2005; ## invalid year
$yearNow = date("Y",time());
if ($_POST['year']>$yearNow) $birthYear = $yearNow - 1;
$birthDate=$birthYear."-".$_POST['month']."-".$_POST['day'];
$secondsPassed = daysleft($birthDate,$setts['date_format']);
$userAge=((-1)*($secondsPassed))/(31536000);



That is from formchecker.php, I believe it is called by register.php:


$bdate = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
$currentTime = time();
Magick can never be restrained, but when freely given is thrice regained!

8
trabis
Re: Not exactly an xoops module, but......
  • 2008/6/13 12:57

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


AS you can see there are missing parameters in the form.
There is no hour, minute or second so. You donĀ“t need them anyway so, this might work:

Replace this:
$arrDateTime = explode(" ", $date);
$arrDate = explode("-", $arrDateTime[0]);
$arrTime = explode(":", $arrDateTime[1]);
$daysleft=mktime($arrTime[0],$arrTime[1],$arrTime[2],$arrDate[1],$arrDate[2],$arrDate[0]);

With this:
$arrDate = explode("-", $date);
$daysleft=mktime(0,0,0,$arrDate[1],$arrDate[2],$arrDate[0]);


9
preachur
Re: Not exactly an xoops module, but......
  • 2008/6/13 14:50

  • preachur

  • Just can't stay away

  • Posts: 525

  • Since: 2006/2/4 4


IT WORKS!!!! THANK YOU TRABIS!!! THANK YOU SO MUCH!!!!!
Magick can never be restrained, but when freely given is thrice regained!

Login

Who's Online

381 user(s) are online (244 user(s) are browsing Support Forums)


Members: 0


Guests: 381


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits