Author |
Message |
jaredg16
New Member


Joined: Jun 27, 2006
Posts: 15
Location: Baton Rouge, LA
|
Posted:
Wed Jun 28, 2006 2:53 pm |
|
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)
|
|
|
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Wed Jun 28, 2006 2:59 pm |
|
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! |
|
|
 |
jaredg16

|
Posted:
Wed Jun 28, 2006 3:05 pm |
|
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

|
Posted:
Wed Jun 28, 2006 5:52 pm |
|
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

|
Posted:
Thu Jul 06, 2006 2:58 pm |
|
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
|
Posted:
Thu Jul 06, 2006 4:55 pm |
|
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. |
|
|
|
 |
gregexp
The Mouse Is Extension Of Arm

Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Thu Jul 06, 2006 5:25 pm |
|
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!! |
|
 |
 |
jaredg16

|
Posted:
Fri Jul 07, 2006 8:04 am |
|
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!
J |
|
|
|
 |
|