Results 1 to 8 of 8

Thread: Videos Watched total not incrementing

  1. #1
    Join Date
    Oct 2007
    Posts
    126

    Default Videos Watched total not incrementing

    I am just now noticing that in my profile the Videos Watched total is not increasing and is 0. When I look in the database (user.user_video_viewed) the number is 0 and has never had an increase ever.

    I have done modifications to my scripts but am not sure which mod could have shut off the correct line. I have not modified my view_video.php. So it must be another file somewhere calling this php.

    Profile view is working.
    Vshare 2.7

    Did I delete a line somewhere in the video layout page that sends the view info to another page for entry in the database?
    The site I am working on is DiligentHeed.com
    CasselmanCanada.com (free access)


  2. #2
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    That is actually being set from the view_video.php file. In the file, line's 156-162, it states:

    PHP Code:
     if ($_SESSION['UID'] != $video_info['video_user_id'])
            {
                
    $sql "UPDATE `users` SET
                       `user_video_viewed`=`user_video_viewed`+1 WHERE
                       `user_id`='" 
    . (int) $video_info['video_user_id'] . "'";
                
    mysql_query($sql) or mysql_die($sql);
            } 
    If your total isn't increasing (and the user is logged in, watching videos), then this line is either commented out or missing altogether.

    Also, make sure that in your user.tpl file, you have something similiar to:

    PHP Code:
    Videos Watched <b>{$user_info.user_video_viewed}</btimes<br /> 
    And not something like:

    PHP Code:
    Videos Watched <b>0</btimes<br /> 
    Because that would do it too.
    Last edited by bplex; 12-30-2010 at 04:37 AM.
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  3. #3
    Join Date
    Oct 2007
    Posts
    126

    Default Videos Watched total not incrementing

    Thanks bplex for shooting me back to the view_video.php file.

    More testing shows that incrementation only occurs if a user is logged in and he watches a video that is not his own. Incrementation will not occur if you watch your own video while logged in. And incrementation does not occur if the viewer is not logged in.

    So, my site has no users that log in and therefore had no views adding up. However if I look at individual views for videos I can see numbers increasing.

    Question/Comment: I guess I should remove the if condition surrounding the incrementation code to allow guests to cause the incrementing also.

    if ($_SESSION['UID'] != $video_info['video_user_id'])

    Nope, tried removing that line and it makes no difference. Why not? The UID would be the guest IP address so it should work either way??!!
    I am copying my code in case there is a wrong character I am not seeing here.
    $sql = "UPDATE `users` SET
    `user_video_viewed`=`user_video_viewed`+1 WHERE
    `user_id`='" . (int) $video_info['video_user_id'] . "'";
    mysql_query($sql) or mysql_die($sql);
    Last edited by jayscot; 01-02-2011 at 06:08 AM.
    CasselmanCanada.com (free access)


  4. #4
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    I guess I'm a little lost here? That code updates the total number of videos that an individual user watches. So, when you go to your individual profile for that user, you can see how many videos that particular user has watched. The video's total views are recorded whether someone logs in or not. That is stored on the video itself (and not on the user). So, for each video, you have a total number of views. On a persons profile, you have a total number of videos that that particular person has watched.

    Question for you:

    Are you wanting to see a total for the number of times an individual's videos has been watched? For example, if I uploaded 50 videos and each video was watched 10 times, are you wanting to see something like "My videos have been watched 500 times"?
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  5. #5
    Join Date
    Oct 2007
    Posts
    126

    Default

    Quote Originally Posted by bplex View Post
    I guess I'm a little lost here? That code updates the total number of videos that an individual user watches. So, when you go to your individual profile for that user, you can see how many videos that particular user has watched. The video's total views are recorded whether someone logs in or not. That is stored on the video itself (and not on the user). So, for each video, you have a total number of views. On a persons profile, you have a total number of videos that that particular person has watched.
    No, I am not sure you have me convinced.

    I went to one of my sites (oldskoolmedia.net), and viewed my profile which shows Videos Watched, Profile Views and my Watched videos (while logged in). Then I logged in as a different user and checked the numbers again. Only the profile viewed had increased. I then watched one of the videos owned by that user. Then clicked on the username to get back to the profile and the Videos Watched had increased.

    When I went to my own profile and checked the Videos Viewed number, then viewed one of my videos and then went back to check the number it had not incremented - meaning I could not increase my own number.

    You could try it for yourself on your site or on mine. (You would have to create an account to test on oldskoolmedia.net, but it would get deleted in a few days as it is a private site)

    So if the above description is indeed what is happening in v2.7, do I have something unique or is it something that has not been noticed by others?


    Quote Originally Posted by bplex View Post
    Question for you:

    Are you wanting to see a total for the number of times an individual's videos has been watched? For example, if I uploaded 50 videos and each video was watched 10 times, are you wanting to see something like "My videos have been watched 500 times"?
    Yep, that is it. Seems to work on one site (oldskoolmedia.net) but I have muddled it up on the other sites.

    I went to another of my sites (CasselmanCanada.com). It has free access with no login or viewer packages. My profile shows 70843 Videos Watched, but no matter how many videos I try to watch the number does not increase. I tried cleaning out my guest cache in the database but it does not affect the counter. I have no idea where the number came from, although the other two numbers in the profile are working correctly.
    CasselmanCanada.com (free access)


  6. #6
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    Ok, so you are referring to the section of the page that says "Videos Watched X times" and not the "I've watched X videos" then. Interestingly, I looked at a vanilla demo site (vShare 2.7) that I have setup and it shows that my videos have been watched "0" times although I have looked at them before. This appears to be a bug. I'd have to look to see where it is as to fix it.
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  7. #7
    Join Date
    Sep 2008
    Posts
    1,019

    Default

    Ok, after looking further into the code, this isn't a bug, per say, although it appears to function as one.

    The way that the code is written in vShare 2.7, a user must be logged in for any of those fields to be updated (Watched Videos or I've Watched, etc). Then, it only updates the videos if the user is not looking at their own videos (but someone elses). So, the behavior that you described is correct. If you want to change this behavior, you would need to replace lines 149-176 of the view_video.php code from:

    PHP Code:

    if (isset($_SESSION['UID']))
        {
            
    $sql "UPDATE `users` SET
                   `user_watched_video`=`user_watched_video`+1 WHERE
                   `user_id`='" 
    . (int) $_SESSION['UID'] . "'";
            
    mysql_query($sql) or mysql_die($sql);
            
            if (
    $_SESSION['UID'] != $video_info['video_user_id'])
            {
                
    $sql "UPDATE `users` SET
                       `user_video_viewed`=`user_video_viewed`+1 WHERE
                       `user_id`='" 
    . (int) $video_info['video_user_id'] . "'";
                
    mysql_query($sql) or mysql_die($sql);
            }
            
            
    $sql "SELECT * FROM `playlists` WHERE
                   `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "' AND
                   `playlist_video_id`='" 
    . (int) $video_id "'";
            
    $result mysql_query($sql) or mysql_die($sql);
            
            if (
    mysql_num_rows($result) == 0)
            {
                
    $sql "INSERT INTO `playlists` SET
                       `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "',
                       `playlist_video_id`='" 
    . (int) $video_id "'";
                
    $result mysql_query($sql) or mysql_die($sql);
            }
        } 
    To

    PHP Code:

    if (isset($_SESSION['UID']))
        {
            
    $sql "UPDATE `users` SET
                   `user_watched_video`=`user_watched_video`+1 WHERE
                   `user_id`='" 
    . (int) $_SESSION['UID'] . "'";
            
    mysql_query($sql) or mysql_die($sql);
            
             
            
    $sql "SELECT * FROM `playlists` WHERE
                   `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "' AND
                   `playlist_video_id`='" 
    . (int) $video_id "'";
            
    $result mysql_query($sql) or mysql_die($sql);
            
            if (
    mysql_num_rows($result) == 0)
            {
                
    $sql "INSERT INTO `playlists` SET
                       `playlist_user_id`='" 
    . (int) $_SESSION['UID'] . "',
                       `playlist_video_id`='" 
    . (int) $video_id "'";
                
    $result mysql_query($sql) or mysql_die($sql);
            }
        }
        
    $sql "UPDATE `users` SET
                `user_video_viewed`=`user_video_viewed`+1 WHERE
                `user_id`='" 
    . (int) $video_info['video_user_id'] . "'";
        
    mysql_query($sql) or mysql_die($sql); 
    vShare Solutions
    Custom vShare Modules and Services

    Now, your visitors can watch videos on your site using their mobile or tablet device with the Mobility Mod for vShare 2.8!

  8. #8
    Join Date
    Oct 2007
    Posts
    126

    Default

    That is the same conclusion I had come to when I started looking for answers. I had it down to the right section of code. Good thing a programmer like you knows how to move the lines around to make the stuff work properly.

    I changed the code on a couple of my sites and now the numbers are increasing properly.

    Thanks bplex.
    CasselmanCanada.com (free access)


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •