Forum Moderators: coopster
I am trying to find a free statcounter that will work with my index.php page. I do have a statcounter account at statcounter.com and I did read about adding echo ' in front of all the html code and ending with '; but for some reason when I try to do this, it doesn't work for me I get some sort of syntax error, I think I must be putting to many ';'s in the code. I do not know much about PHP, any help would be appreciated.
Here is my statcounter code if someone wants to modify it for me so I can use it with my index.php, I would greatly appreciate your help.
<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=5193783;
var sc_invisible=1;
var sc_partition=34;
var sc_click_stat=1;
var sc_security="7d7c60c9";
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter.js"></script><noscript><div
class="statcounter"><a title="counters for myspace"
href="http://www.statcounter.com/myspace/"
target="_blank"><img class="statcounter"
src="http://c.statcounter.com/5193783/0/7d7c60c9/1/"
alt="counters for myspace" ></a></div></noscript>
<!-- End of StatCounter Code -->
<?php
$server = '#*$!x; // MySQL hostname
$username = '#*$!x'; // MySQL username
$password = '#*$!x'; // MySQL password
$dbname = '#*$!x'; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = 'SELECT
country
FROM
ip2nation
WHERE
ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'")
ORDER BY
ip DESC
LIMIT 0,1';
list($country) = mysql_fetch_row(mysql_query($sql));
switch ($country) {
case 'se':
// Get the Swedish to a Swedish
header('Location: [mysite.com');...]
exit;
case 'us':
// And redirect US visitors to
header('Location: [mysite.com);...]
exit;
default:
// The rest of the world can go to
header('Location: [mysite.com);...]
exit;
}
?>
One option may be to include your stat tracking automatically using the PHP auto_prepend configuration directive. Or if you are using any type of navigational server-side include for a header, menu, footer, etc. you could embed the code there too.