Hi guys (and gals),

i am having a very strange problem with an insertion query in wordpress, i am trying to track how many times members click on links from a certain page but every time a link is clicked it inserts 2 links at the same time, 1 that you actually clicked on and another that is totally different! even some of the links that is being entered are on a totally different page. I have been fussing with this problem for the past few days now and can not figure it out, hopefully someone out there can help as this project is already a couple weeks behind schedule. Heres my query:

PHP Code:

if($_SESSION['member_id']){
    
$logged=mysql_query("select * from members where member_id = '".$_SESSION['member_id']."'");

$row=mysql_fetch_array($logged);

$member_id $row['member_id'];
$company_id $row['company_id'];

$check=mysql_query("SELECT * from analytics where member_id = '$member_id' AND company_id = '$company_id' AND temp_id = 'vid' AND page_url='http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."'")or die(mysql_error());

$row=mysql_fetch_array($check);

$member_id $row['member_id'];
$company_id $row['company_id'];
$num_hits $row['num_hits'];
$page_url $row['page_url'];
$temp_id $row['temp_id'];

if(
$member_id == '' && $company_id == '' && $temp_id == '' && $page_url == ''){
    
mysql_query("INSERT INTO analytics (member_id,company_id,num_hits,temp_id,page_url)VALUES('".$_SESSION['member_id']."','".$company_id."','1','vid','http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."')") or die (mysql_error()."in <br>$query" );
//$result = mysql_query($query) or die (mysql_error()."in <br>$query" );

}