Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
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

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: 6437

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

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 search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
jaredg16







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

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
 
jaredg16







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

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?
 
jaredg16







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

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?
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

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

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
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

looks like they are running it twice. the second time will output nothing, just run the query.

_________________
For those who stand shall NEVER fall and those who fall shall RISE once more!! 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
jaredg16







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

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
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©