Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-26-2008, 04:54 PM Leap year problem
Novice Talker

Posts: 8
Trades: 0
how do I fix this?? Thanks


Here is an error I got on a script

Fatal error: Call to a member function isLeapYear() on a non-object in /home/public_html/remind1blue/include/common.php on line 247

Here is the code

PHP Code:
<?
 session_start
();
 include(
"config.php");
 
$edu_level['1']='High School degree';
 
$edu_level['2']='Undergraduate degree';
 
$edu_level['3']='Bachelor\'s degree';
 
$edu_level['4']='Master\'s degree';
 
$edu_level['5']='Doctoral degree';
 
$edu_level['6']='Post-doctoral degree';
 
$edu_level['7']='Training';
 
$edu_level['8']='Other';

 
$paypal_item $sitename." Service Monthly Subscription";
 
$paypal_item_number $sitename;
 
$mainipn $siteurl."/ipn.php";
 
$paypal_ipn $siteurl."/site_ipn.php";
 
$paypal_cancel_return $siteurl."/cancel.php";
 
$paypal_return $siteurl."/thanks.php";
 
$this->min_pass_length=8;
 
$this->max_pass_length=12;
 
$this->chars='abcdefghijklmnopqrstuvwxyz0123456789';
 
$logfile "logfile.txt";
 
$postmode 1;
 
$invalidcode "<table bgcolor=#ffffff cellpadding=4 width=170><tr><td align=center><font size=2><b>Invalid Button Code!</b><p>Run Your Own PayPal Donation Campaigns at <a href=$siteurl/join.php>$sitename</a></font></table>";
 
$table1 "<TABLE class=design bgColor=#ffffff cellPadding=3 cellSpacing=0 width=100% border='1' BORDERCOLOR='#C0C0C0' STYLE='border-collapse: collapse'>";
 
$table2 "<TABLE class=design bgColor=#ffffff cellPadding=3 cellSpacing=0 width=100% border='1' BORDERCOLOR='#C0C0C0' STYLE='border-collapse: collapse'>";
 
$table3 "<TABLE class=design bgColor=#ffffff cellPadding=3 cellSpacing=0 width=100% border='1' BORDERCOLOR='#C0C0C0' STYLE='border-collapse: collapse'>";
 @
mysql_connect($dbServer$dbUser$dbPass) or die("Couldn't connect to database server: " mysql_error());
 @
mysql_select_db($dbName) or die("Couldn't connect to database: " mysql_error());
 
 function 
errform($msg$var ''){ 
  global 
$posterr$_POST
  
$posterr 1
  echo 
"<div style='color: #FF0000;'>$msg</div>";
  if (
$var$_POST[$var] = '';
 }
 
 function 
buildDateBox($type,$name,$sel){
  
$months = Array(
    
"1"=>"January",
    
"2"=>"February",
    
"3"=>"March",
    
"4"=>"April",
    
"5"=>"May",
    
"6"=>"June",
    
"7"=>"July",
    
"8"=>"August",
    
"9"=>"September",
    
"10"=>"October",
    
"11"=>"November",
    
"12"=>"December");
?>
  <SELECT NAME="<?=$name?>">
<?
  
switch($type){
   case 
"d":
    echo 
"<option value=''>-----";
    for(
$i 1;$i <= 31;$i++){
     
$arlist[$i] = $i;
    }
    break;
   case 
"y":
    echo 
"<option value=''>-----";
    
$year = (date("Y")+10);
    for(
$i $year;$i >= 2004;$i--){
     
$arlist[$i] = $i;
    }
    break;
   case 
"m":
   default:
    echo 
"<option value=''>-----";
    
$arlist $months;
    break;
  }
  while( list(
$i,$val) = each($arlist) ){
   if(
$sel == $i){
    echo 
"<OPTION VALUE=\"$i\" SELECTED>$val</OPTION>\n"
   }else{
    echo 
"<OPTION VALUE=\"$i\">$val</OPTION>\n"
   }
  }
?>
  </select>
<?
 
}
 function 
buildTimeBox($type,$name,$sel){
   
$types = Array(
     
"0"=>"AM",
     
"1"=>"PM"
    
);
?>
  <SELECT NAME="<?=$name?>">
<?
  
switch($type){
   case 
"m":
    echo 
"<option value=''>-----";
    for(
$i 0;$i <= 55;$i++){
     
$arlist[$i] = $i;
    }
    break;
   case 
"t":
    echo 
"<option value=''>-----";
    
$arlist $types;
    break;
   case 
"h":
   default:
    echo 
"<option value=''>-----";
    for(
$i 1;$i <= 12;$i++){
     
$arlist[$i] = $i;
    }
    break;
  }
  while( list(
$i,$val) = each($arlist) ){
   if(
$sel == $i){
    echo 
"<OPTION VALUE=\"$i\" SELECTED>$val</OPTION>\n"
   }else{
    echo 
"<OPTION VALUE=\"$i\">$val</OPTION>\n"
   }
  }
?>
  </select>
<?
 
}

 function 
edulevel($name,$sel){
  global 
$edu_level;
  
reset($edu_level);
  echo 
"<select name='$name'>";
  while( list(
$i,$val) = each($edu_level) ){
   if(
$sel == $i){
    echo 
"<OPTION VALUE=\"$i\" SELECTED>$val</OPTION>\n"
   }else{
    echo 
"<OPTION VALUE=\"$i\">$val</OPTION>\n"
   }
  }
  echo 
"</select>";
 }
 function 
myround($amt,$dec="3"){
  
ob_start();
  if(
$dec == 2){
   
printf("%6.2f",$amt);
  }else{
   
printf("%6.3f",$amt);
  }
  
$amount ob_get_contents();
  
ob_end_clean(); 
  
$amount str_replace(" ","",$amount);
  return 
$amount;
 }
 class 
fptime{
  function 
fptime(){
   return 
1;
  }
  function 
mytime($stamp="",$format="m/d/Y"){
   return 
date$format,($stamp $stamp time()) );
  }
  function 
stamp($mm,$dd,$yy,$hh=0,$min=0,$sec=0){
   return 
mktime($hh,$min,$sec,$mm,$dd,$yy);
  }
  function 
subhours($interval,$mm,$dd,$yy,$hh,$m,$s){
   return 
$this->stamp$mm,$dd,$yy,($hh-$interval),$m,$s );
  }
  function 
addhours($interval,$mm,$dd,$yy,$hh,$m,$s){
   return 
$this->stamp$mm,$dd,$yy,($hh+$interval),$m,$s );
  }
  function 
subdays($interval,$mm,$dd,$yy){
   return 
$this->stamp($mm,($dd-$interval),$yy);
  }
  function 
adddays($interval,$mm,$dd,$yy,$hh=0,$min=0,$sec=0){
   return 
$this->stamp($mm,($dd+$interval),$yy,$hh,$min,$sec);
  }
  function 
submonths($interval,$mm,$dd,$yy){
   return 
$this->stamp( ($mm-$interval),$dd,$yy );
  }
  function 
addmonths($interval,$mm,$dd,$yy){
   return 
$this->stamp( ($mm+$interval),$dd,$yy );
  }
  function 
subyears($interval,$mm,$dd,$yy){
   return 
$this->stamp$mm,$dd,($yy-$interval) );
  }
  function 
addyears($interval,$mm,$dd,$yy){
   return 
$this->stamp$mm,$dd,($yy+$interval) );
  }
  function 
DateDiff ($interval$date1,$date2) {
   
// get the number of seconds between the two dates
   
$timedifference =  $date2 $date1;
   switch (
$interval) {
    case 
"w":
     
$retval $timedifference/604800;
     
$retval floor($retval);
     break;
    case 
"d":
     
$retval $timedifference/86400;
     
$retval floor($retval);
     break;
    case 
"h":
     
$retval $timedifference/3600;
     
$retval floor($retval);
     break;
    case 
"n":
     
$retval $timedifference/60;
     
$retval floor($retval);
     break;
    case 
"s":
     
$retval  floor($timedifference);
     break;
   }
   return 
$retval;
  }
  function 
dateNow($format="%Y%m%d"){
   return(
strftime($format,time()));
  }
  function 
dateToday(){
   
$ndate time();
   return( 
$ndate );
  }
  function 
daysInMonth($month="",$year=""){
   if(empty(
$year)) {
    
$year $this->dateNow("%Y");
   }
   if(empty(
$month)) {
    
$month $this->dateNow("%m");
   }
   if(
$month == 2) {
    if(
$this->isLeapYear($year)) {
     return 
29;
    } else {
     return 
28;
    }
   } elseif(
$month == or $month == or $month == or $month == 11) {
    return 
30;
   } else {
    return 
31;
   }
  }
  function 
isLeapYear($year=""){
   if(empty(
$year)) {
    
$year $this->dateNow("%Y");
   }
   if(
strlen($year) != 4) {
    return 
false;
   }
   if(
preg_match("/\D/",$year)) {
    return 
false;
   }
   return ((
$year == && $year 100 != 0) || $year 400 == 0);
  }
 }
?>
teamcro is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-26-2008, 06:00 PM Re: Leap year problem
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
At a glance, it looks like you are using $this incorrectly.

Try removing $this in your if statment (so just change it to if(isLeapYear($year)) )
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-26-2008, 06:16 PM Re: Leap year problem
Novice Talker

Posts: 8
Trades: 0
I changed $this to $that and I still get the error.

Tried it and no luck doesn't work.


Thanks

Last edited by teamcro; 02-26-2008 at 06:30 PM..
teamcro is offline
Reply With Quote
View Public Profile
 
Old 02-26-2008, 06:42 PM Re: Leap year problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Originally Posted by teamcro View Post
I changed $this to $that and I still get the error.
Huu?
What for ?

NullPointer told you to remove $this, not replace it with any other value.

$this is only valid into an object class definition.
This code is not a class, so $this cannot apply.
Try to call the function alone without any prefix.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Leap year problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14558 seconds with 12 queries