Javascript i .php-fil
HejsaJeg har nedenstående .php-fil som laver redirect
Men jeg vil gerne kunne måle med google analytics
Jeg er en "nød" til programmering, og har ikke den fjerneste anelse om hvordan det skal sættes sammen
Er der en der kan hjælpe mig med at få det rigtigt sat sammen
-----------------------------------------------------
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-1234567-8");
pageTracker._trackPageview();
</script>
-----------------------------------------------------
<?php
// Short URL Script - Settings
$Path_To_Script = "http://www.domain.com/m.php"; // e.g http://www.yourdomain.com/m.php
$Database_Username = "username";
$Database_Password = "password";
$Database_Name = "database_Nam";
$Database_Host = "db_host.com";
$Not_Found = "http://www.domain.com"; // The page to redirect to if no redirect link is found in the database.
$get_id = $_SERVER['QUERY_STRING'];
function shorturl_error($error){
echo $error;
}
if($get_id){
$DBConn = mysql_connect($Database_Host, $Database_Username, $Database_Password) or die(shorturl_error("Could not connect to database server. Check your settings."));
$DB_DB = mysql_select_db($Database_Name, $DBConn) or die(shorturl_error("Could not connect to database ($Database_Name). Perhaps you don't have the right permissions on this DB. Check your settings"));
$sql = mysql_query("SELECT link_url FROM shorturl WHERE link_id='$get_id'");
$site_arr = mysql_fetch_array($sql);
$site_redirect = $site_arr['link_url'];
if(!$site_arr){ header("Location: $Not_Found"); }
if($site_arr){
mysql_query("UPDATE shorturl SET link_count = link_count + 1 WHERE link_id='$get_id'");
header("Location: $site_redirect");
}
}
-----------------------------------------------------