Jump to content

mail stats


pietbez

Recommended Posts

can anyone spot the problem?

this script lets me see how many of my members actualy open thier news letters.

There are 2 tables. "mail_stats" and "members" they both have a field called "clicks"

i need these to be the same at all times, but for some reason, "members" lag behind by one the whole time.

when mail_stats/clicks is "1" , members/clicks is still at "0" and so on.

 

hope my explination is clear.

thanks

 

<?php

include './global_functions.php';
$img = './img.gif';

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

$mail_id = intval($_GET['id']);
$user_id = intval($_GET['u']);

if ($mail_id != '' and $user_id != '')
$tmp = $db->sql_query("SELECT clicks FROM mail_stats WHERE user_id = '$user_id' and mail_id = '$mail_id'");
if ($db->sql_numrows($tmp) > 0)
{
$q = "UPDATE mail_stats SET clicks=clicks+1 WHERE user_id = '$user_id' and mail_id = '$mail_id'";
$db->sql_query("UPDATE members SET clicks=clicks+1 WHERE id = '$user_id'");
}
else
{
$q = "INSERT INTO mail_stats values ('$user_id', '$mail_id', 1)";
}

$db->sql_query($q);

header('Location: '.$img);
return;

?>

Link to comment
https://forums.phpfreaks.com/topic/91877-mail-stats/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.