Location: PHPKode > scripts > Real Counter > Test.php
<?php
/*
 * Simple example in debugger mode
--
-- Table structure for table `counter_visitors`
--

CREATE TABLE IF NOT EXISTS `counter_visitors` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `agent` varchar(512) NOT NULL,
  `ip` char(15) NOT NULL,
  `page` varchar(512) NOT NULL,
  `last_impression` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

--
-- Dumping data for table `counter_visitors`
--

INSERT INTO `counter_visitors` (`id`, `agent`, `ip`, `page`, `last_impression`) VALUES
(7, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8', '::1', '', '2010-03-08 22:26:50'),
(6, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8', '::1', '', '2010-03-08 22:26:50'),
(8, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8', '::1', '/Counter/test.php', '2010-03-08 22:26:50'),
(9, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8', '::1', '/Counter/test.php', '2010-03-08 22:26:50'),
(10, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8', '::1', '/Counter/test.php', '2010-03-08 22:30:33');

-- --------------------------------------------------------

--
-- Table structure for table `counter_visits`
--

CREATE TABLE IF NOT EXISTS `counter_visits` (
  `id` int(10) NOT NULL,
  `page` varchar(256) NOT NULL,
  `visit` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `counter_visits`
--

INSERT INTO `counter_visits` (`id`, `page`, `visit`) VALUES
(0, '/Counter/test.php', 16);
 */
ini_set("display_errors","On");
$link = mysql_connect('localhost', 'root', 'pass');
if (!$link) {
    die('Not connected : ' . mysql_error());
}

// make foo the current db
$db_selected = mysql_select_db('development', $link);
if (!$db_selected) {
    die ('Can\'t use development: ' . mysql_error());
}


 include("Class.Counter.php");
 $counter = new counter(true);
 echo "The current page has been shown ".$counter->getPageVisits()." times<br />";
 echo "Actually, ".$counter->getPageVisitors()." different people has seen it!<br />";
 
?>
Return current item: Real Counter