Results 1 to 8 of 8

Thread: Videos Watched total not incrementing

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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!

  2. #2
    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!

  3. #3
    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
  •