Ok, I got some PHP code that is supposed to track the impressions of a link via Links SQL (its gonna be a free plugin). I'm having a bit of a problem with it though as it doesn't seem to be tracking it correctly. The site I am testing it on reveives about 500k hits a day. Each page has 20 links on it. So, the approx number of calls for it is 10,000,000.
Now, for some reason, we tested a link, and it said that it was viewed 900 times. However, we put an image on the page at the bottom to see how impressions that link received and it got 39k (we tracked this with the system log). Could it be down to the fact that I'm using several queries and then re-submitting the information into the database? If so, is there a query that would do it all in one go? The code is below;
// set up the connection
$connection = mysql_connect("localhost", "", "");
if (!$connection) { error("Unable to connect with your login info for MySQL", $connection); }
// connect the database
$db = mysql_select_db("', $connection);
if (!$db) { error("Unable to connect to database", $connection); }
// set up the query
$query = "SELECT * FROM Links_Links WHERE ID = $id";
// now do a while to print out the HTML code to show the categories..
$result = mysql_query($query);
if (!$result) { error("Unable to execute query to mySQL Database.", $connection); }
//start putting into the HTML
while ($cat = mysql_fetch_array($result)) {
$count = $cat[view];
} // end of the while
$count++;
mysql_close($connection);
// set up the connection
$connection = mysql_connect("localhost", "", "");
if (!$connection) { error("Unable to connect with your login info for MySQL", $connection); }
// connect the database
$db = mysql_select_db("", $connection);
if (!$db) { error("Unable to execute command", $connection); }
// now create ther query and use it to update the field number...
$query = "UPDATE Links_Links SET view = $count WHERE ID = $id";
$result = mysql_query($query);
$error = mysql_error();
if (!$result) { error("Unable to execute query to mySQL Database! Reason: $error", $connection); }
mysql_close($connection);
echo "<img src=\"http://www.site.com/pixel.gif\" width=1 height=1>";
// erorr sub incase we get probs!
function error($error, $connection) {
echo $error;
mysql_close($connection);
exit;
}
Thanks for any help you guys can provide
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Now, for some reason, we tested a link, and it said that it was viewed 900 times. However, we put an image on the page at the bottom to see how impressions that link received and it got 39k (we tracked this with the system log). Could it be down to the fact that I'm using several queries and then re-submitting the information into the database? If so, is there a query that would do it all in one go? The code is below;
Code:
if (!$id) { error("You didnt specify an id number"); } // set up the connection
$connection = mysql_connect("localhost", "", "");
if (!$connection) { error("Unable to connect with your login info for MySQL", $connection); }
// connect the database
$db = mysql_select_db("', $connection);
if (!$db) { error("Unable to connect to database", $connection); }
// set up the query
$query = "SELECT * FROM Links_Links WHERE ID = $id";
// now do a while to print out the HTML code to show the categories..
$result = mysql_query($query);
if (!$result) { error("Unable to execute query to mySQL Database.", $connection); }
//start putting into the HTML
while ($cat = mysql_fetch_array($result)) {
$count = $cat[view];
} // end of the while
$count++;
mysql_close($connection);
// set up the connection
$connection = mysql_connect("localhost", "", "");
if (!$connection) { error("Unable to connect with your login info for MySQL", $connection); }
// connect the database
$db = mysql_select_db("", $connection);
if (!$db) { error("Unable to execute command", $connection); }
// now create ther query and use it to update the field number...
$query = "UPDATE Links_Links SET view = $count WHERE ID = $id";
$result = mysql_query($query);
$error = mysql_error();
if (!$result) { error("Unable to execute query to mySQL Database! Reason: $error", $connection); }
mysql_close($connection);
echo "<img src=\"http://www.site.com/pixel.gif\" width=1 height=1>";
// erorr sub incase we get probs!
function error($error, $connection) {
echo $error;
mysql_close($connection);
exit;
}
Thanks for any help you guys can provide
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!