Forums / General Questions / Fatal Error with the Counter.php

Fatal Error with the Counter.php

Locked

Started by tig on 18 Aug 2006, 4:18 PM · Views: 4,326

Results 1 to 18 of 18
This thread is locked. New replies are disabled.
18 Aug 2006, 4:18 PM
#1
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Fatal Error with the Counter.php

Fatal error: Call to a member function Execute() on a non-object in /home/.ambale/whiskeyb/dicksgeneral.com/includes/counter.php on line 23

$date_now = date('Ymd');
$counter_query = "select startdate, counter, session_counter from " . TABLE_COUNTER_HISTORY . " where startdate='" . $date_now . "'";
[b]LINE 23 ---->[/b] $counter = $db->Execute($counter_query); [b]<---- LINE 23[/b]
if ($counter->RecordCount() <= 0) {
  $date_now = date('Ymd');
  $sql = "insert into " . TABLE_COUNTER_HISTORY . " (startdate, counter, session_counter) values ('" . $date_now . "', '1', '1')";
  $db->Execute($sql);
  $counter_startdate = $date_now;
  $counter_now = 1;
} else {
  $counter_startdate = $counter->fields['startdate'];
  $counter_now = ($counter->fields['counter'] + 1);
  $session_counter_now = ($counter->fields['session_counter'] + $session_counter);
  $sql = "update " . TABLE_COUNTER_HISTORY . " set counter = '" . $counter_now . "', session_counter ='" . $session_counter_now . "' where startdate='" . $date_now . "'";
  $db->Execute($sql);
}

How do I fix this error?

Much Thanks!

18 Aug 2006, 4:31 PM
#2
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Which version of PHP?

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

18 Aug 2006, 4:37 PM
#3
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

PHP v5.1.2

18 Aug 2006, 4:40 PM
#4
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Ok
Does this error occurs only for counter?
Are all other pages working fine?
San

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

18 Aug 2006, 4:58 PM
#5
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

As far as I know, everything else works fine.

I just applied the new security update (which doens't touch the coutner.php file) and when I went to load the page to see if there way anything I need to fix and I got hit with the error.

18 Aug 2006, 5:00 PM
#6
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

can you post the complete counter.php file here?

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

18 Aug 2006, 5:04 PM
#7
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

<?php
/**
 * counter.php
 *
 * @package general
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: counter.php 3194 2006-03-15 23:17:53Z wilt $
 * @private
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if (isset($_SESSION['session_counter']) && $_SESSION['session_counter'] == true) {
  $session_counter = 0;
} else {
  $session_counter = 1;
  $_SESSION['session_counter'] = true;
}
$date_now = date('Ymd');
$counter_query = "select startdate, counter, session_counter from " . TABLE_COUNTER_HISTORY . " where startdate='" . $date_now . "'";
$counter = $db->Execute($counter_query);
if ($counter->RecordCount() <= 0) {
  $date_now = date('Ymd');
  $sql = "insert into " . TABLE_COUNTER_HISTORY . " (startdate, counter, session_counter) values ('" . $date_now . "', '1', '1')";
  $db->Execute($sql);
  $counter_startdate = $date_now;
  $counter_now = 1;
} else {
  $counter_startdate = $counter->fields['startdate'];
  $counter_now = ($counter->fields['counter'] + 1);
  $session_counter_now = ($counter->fields['session_counter'] + $session_counter);
  $sql = "update " . TABLE_COUNTER_HISTORY . " set counter = '" . $counter_now . "', session_counter ='" . $session_counter_now . "' where startdate='" . $date_now . "'";
  $db->Execute($sql);
}

$counter_query = "select startdate, counter from " . TABLE_COUNTER;
$counter = $db->Execute($counter_query);
if ($counter->RecordCount() <= 0) {
  $date_now = date('Ymd');
  $sql = "insert into " . TABLE_COUNTER . " (startdate, counter) values ('" . $date_now . "', '1')";
  $db->Execute($sql);
  $counter_startdate = $date_now;
  $counter_now = 1;
} else {
  $counter_startdate = $counter->fields['startdate'];
  $counter_now = ($counter->fields['counter'] + 1);
  $sql = "update " . TABLE_COUNTER . " set counter = '" . $counter_now . "'";
  $db->Execute($sql);
}

$counter_startdate_formatted = strftime(DATE_FORMAT_LONG, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4)));
?>
18 Aug 2006, 5:11 PM
#8
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

File looks fine
Somehow $db is not getting initialised!

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

18 Aug 2006, 5:21 PM
#9
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Lovely.

I've dropped a line to my hosting company. I'll post an update if they reply.

18 Aug 2006, 5:23 PM
#10
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Tig:

Lovely.

I've dropped a line to my hosting company. I'll post an update if they reply.

It seems that some problem happened while doing the upgrade
Who did the upgrade?
Can you show me the steps?

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

18 Aug 2006, 5:30 PM
#11
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

I followed the steps detailed in this thread.

I think I did everything right. I even double-checked before I saved.

19 Aug 2006, 7:13 AM
#12
cosmocanuck avatar

cosmocanuck

New Zenner

Join Date:
Jun 2006
Posts:
85
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Same problem for me - applied the patch, then Fatal Error. Everywhere!

I had to restore the old files - a chance i have to take - too late in the evening to start debugging... I'll keep an eye on the thread and hopefully The Answer will be forthcoming!

Thanks,
Cosmo

19 Aug 2006, 7:31 AM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Fatal Error with the Counter.php

when you edited application_top.php ... did you INSERT the new line, or replace the existing line?
The instructions are to add the new line.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Aug 2006, 2:39 PM
#14
flash avatar

flash

New Zenner

Join Date:
Mar 2004
Location:
Fort Collins, CO :: Play Hockey eh?!
Posts:
60
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

I expect it should look like this (at least mine does and eliminated the error):

$autoLoadConfig = array();  // Security addition 8-2006
include($base_dir . $loader_file);
if ($loader_dir = dir(DIR_WS_INCLUDES . 'auto_loaders')) {
  while ($loader_file = $loader_dir->read()) {
    if ((preg_match('/^config\./', $loader_file) > 0) && (preg_match('/\.php$/', $loader_file) > 0)) {
      if ($loader_file != 'config.core.php') {
        $base_dir = DIR_WS_INCLUDES . 'auto_loaders/';
        if (file_exists(DIR_WS_INCLUDES . 'auto_loaders/overrides/' . $loader_file)) {
          $base_dir = DIR_WS_INCLUDES . 'auto_loaders/overrides/';
        }

Flash

Larry 'Flash' Alexander
FLASH HQ

19 Aug 2006, 7:21 PM
#15
tig avatar

tig

Zen Follower

Join Date:
Apr 2006
Location:
Lansing, MI
Posts:
123
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Ah ha!

I'm just this side of an idiot. I placed it below where it was supposed to go and forgot the ';'.

Yeesh. I've got to stop doing updates when I'm half asleep.

Thanks guys!

19 Aug 2006, 8:04 PM
#16
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Glad to hear that you got it resolved! :)

Tutorials on Zen Cart
http://tutorials.zen-cart.com/index.php

advanced.programmer at gmail dot com
In love with Zen Cart!!

6 Nov 2006, 9:16 PM
#17
mom2nine avatar

mom2nine

New Zenner

Join Date:
Sep 2004
Location:
USA
Posts:
6
Plugin Contributions:
0

Re: Fatal Error with the Counter.php

Just upgraded to 1.36 from 1.35 and have the same error message. My server is still using PHP version 4.4.3, however. What can I do to get the site working again?

6 Nov 2006, 10:33 PM
#18
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Fatal Error with the Counter.php

What EXACTLY did you do to perform the upgrade?
What contributions and customizations are installed on your site?
It seems like you've missed a file or have customizations that are conflicting with normal flow of activating the database subsystem.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.