Support Forums | Demo Gallery [1.x] [2.x] | Downloads | News | Site Map ]
Nuked Gallery
  Create a FREE account or Login   As a guest, you don't have access to our FULL navigation system.
 Forum FAQForum FAQ   StatisticsStatistics   SearchSearch   UsergroupsUsergroups   FavoritesFavorites  

Error with Code for a Profile View Counter

 
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Issues » Other PHPNuke Issues View previous topicPrinter friendly versionView next topic
Author Message
jaredg16

Wizard
Wizard


Joined: Feb 22, 2006
Posts: 76
Location: Baton Rouge, LA

PostPosted: Wed Jun 28, 2006 6:48 pm    Post subject: Error with Code for a Profile View Counter Reply with quote

I would like to use a profile count for the php-Nuke profile page instead of the php-BB forum profile so I've made a few changes (seen below). However, while I am receiving no errors, The $total_profile_views is equal to zero and is not incrementing. I added the proper tables and fields to my database so I'm fairly certain that the problem lies in the code below. Could you please let me know where I could have made the error?

Quote: ›
// Profile Views MOD, By Manipe (Begin)
$current_time = time();
$delete_time = $current_time - 86400;

//
// Delete old entries
//
$sql = "DELETE FROM ".$prefix."_profile_views WHERE time < '$delete_time'";
if ( !($result = $db->sql_query($sql)) )
{
echo "Could not retreive profile views<br>";
echo mysql_error();
}

//
// Find out if the same person has visited the same user profile
//
$sql = "SELECT ip_address FROM ".$prefix."_profile_views WHERE ip_address = '$user_ip' AND user_id = '" . $userinfo['user_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
echo "Could not retreive profile views<br>";
echo mysql_error();
}
$is_ip_there = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

//
// If so, don't increment the profile views counter
//
if ( empty($is_ip_there['ip_address'][0]))
{
$sql = "INSERT INTO ".$prefix."_profile_views (user_id, time, ip_address) VALUES ('" . $userinfo['user_id'] . "', '$current_time', '$user_ip')";
if ( !($result = $db->sql_query($sql)) )
{
echo "Could not retreive profile views<br>";
echo mysql_error();
}

$sql = "UPDATE ".$prefix."_users SET user_profile_views = user_profile_views + 1 WHERE user_id = '" . $userinfo['user_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
echo "Could not retreive profile views<br>";
echo mysql_error();
}
}

//
// Retrieve the number of views
//
$sql = "SELECT user_profile_views FROM ".$prefix."_users WHERE user_id = '" . $userinfo['user_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
echo "Could not retreive profile views<br>";
echo mysql_error();
}
$row = $db->sql_fetchrow($result);
$total_profile_views = ( $row['user_profile_views'] ) ? $row['user_profile_views'] : 0;
$db->sql_freeresult($result);
// Profile Views MOD, By Manipe (End)
Back to top
Hidden View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
AdBot
   Post subject: Error with Code for a Profile View Counter  

Back to top
Display posts from previous:   
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Issues » Other PHPNuke Issues View previous topicPrinter friendly versionView next topic

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours

Powered by phpBB © phpBB Group



Sponsors: Web HostingDedicated ServersDomain NamesDomain Name RegistrationDedicated Web HostingSearch Engine OptimisationSEOWeb Design New YorkSEO Web DesignWeb hosting AustraliaSEO

6th year online! 2003-2008
Legal • Use of this site consitutes agreement to the Acceptable Use Policy
Hosted by Implosion WorksSourceForge.net Logo • Theme by TonicMedia