PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
jaredg16
New Member
New Member


Joined: Jun 27, 2006
Posts: 15
Location: Baton Rouge, LA

PostPosted: Wed Jun 28, 2006 2:53 pm Reply with quote Back to top

I would like to use this 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)
View user's profile Send private message AIM Address Yahoo Messenger
kguske
Site Admin


Joined: Jun 04, 2004
Posts: 6044

PostPosted: Wed Jun 28, 2006 2:59 pm Reply with quote Back to top

Why not just set the $total_profile_views = $row['user_profile_views'] ? If it's still zero, then you know the problems is accessing the $row['user_profile_views']. If so, turn the php display_errors on so you can see the error and / or add logic to display the database error when retrieving that information.
View user's profile Send private message
jaredg16
New Member
New Member


Joined: Jun 27, 2006
Posts: 15
Location: Baton Rouge, LA

PostPosted: Wed Jun 28, 2006 3:05 pm Reply with quote Back to top

kguske wrote:
Why not just set the $total_profile_views = $row['user_profile_views'] ? If it's still zero, then you know the problems is accessing the $row['user_profile_views']. If so, turn the php display_errors on so you can see the error and / or add logic to display the database error when retrieving that information.


I changed the $total_profile_views line of code to:
Quote:
$total_profile_views = ( $row['user_profile_views'] );

... and now it doesn't show any number at all. What could be causing that?

Here's a stupid question for ya too... How do I turn the php display_errors on?

Thanks in advance for your help!

J
View user's profile Send private message AIM Address Yahoo Messenger
jaredg16
New Member
New Member


Joined: Jun 27, 2006
Posts: 15
Location: Baton Rouge, LA

PostPosted: Wed Jun 28, 2006 5:52 pm Reply with quote Back to top

Whatever I change the
Quote:
$total_profile_views = ( $row['user_profile_views'] ) ? $row['user_profile_views'] : 0;
to shows in the results...

For instance, I changed the "0" to "16" and the results came back as "16".

Any ideas?
View user's profile Send private message AIM Address Yahoo Messenger
jaredg16
New Member
New Member


Joined: Jun 27, 2006
Posts: 15
Location: Baton Rouge, LA

PostPosted: Thu Jul 06, 2006 2:58 pm Reply with quote Back to top

Anyone there reading this? I'd really like some help with this please. I also never heard about how to turn the php display_errors on?
View user's profile Send private message AIM Address Yahoo Messenger
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

PostPosted: Thu Jul 06, 2006 4:55 pm Reply with quote Back to top

The error setting is in config.php
I'm no mySQL expert but please enlighten me, what are you trying to achieve with
Code:
$is_ip_there = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

As I'm a complete noob at this, it looks like you are getting the results of a query and then killing them at the same time.
View user's profile Send private message Send e-mail Visit poster's website
gregexp
The Mouse Is Extension Of Arm


Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol

PostPosted: Thu Jul 06, 2006 5:25 pm Reply with quote Back to top

looks like they are running it twice. the second time will output nothing, just run the query.
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
jaredg16
New Member
New Member


Joined: Jun 27, 2006
Posts: 15
Location: Baton Rouge, LA

PostPosted: Fri Jul 07, 2006 8:04 am Reply with quote Back to top

I don't know what you mean darklord. Could you be more specific?

Guardian2003... I believe that the $is_ip_there is trying to find out if the same person has visited the same user profile. I didn't write this piece of code and it isn't making much sense to me.

I'll be waiting your response darklord! Wink

J
View user's profile Send private message AIM Address Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum