Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer audio black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel explorer firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router security slow software sound trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
How to count how many views a .wmv file received while using a force download option


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
ecoyne's Avatar
Junior Member with 1 posts.
 
Join Date: Jun 2006
Experience: Intermediate
12-Jun-2006, 10:45 PM #1
How to count how many views a .wmv file received while using a force download option
All I originally wanted to do was count how many times my videos were being downloaded.

I'm missing something here and I don't know what it is... I've just started picking up php, so my experience is amateurish at best.

I'm just trying to set up a forced download page that counts downloads and prompts to either Open (stream) or Save As. Currently, when anyone tries to Stream, they get a corrupt file prompt in Windows Media Player using IE. FF downloads the file entirely and then launches Windows Media Player and works fine...

I've hit up php.net, I still can't get it. I would greatly appreciate any help that might get me working properly.

If you guys have ANY other options on how I can do this, I'd greatly appreciate it. I'm about to put up a new video, and I'd really like to get an accurate count as to how many downloads it gets, without users reporting errors all over the place.

The link is: http://www.ecoyne.com/ecoyne_vids.php

The code I'm using is this:
Code:
  # Protect Script against SQL-Injections 
   $id = intval($_GET[id]); 
  # setup SQL statement 
  $sql  = "SELECT * FROM tblVideos WHERE ID='$id'";

  # execute SQL statement 
  $result = mysql_query($sql) or die('Query failed. ' . mysql_error());

       # display results 
       while ($row = mysql_fetch_array($result)) { 
       $filename= $row['FileName']; 
       $filesize= $row['Size']; 
	   $fileurl = 'http://www.ecoyne.com/videos/' .$filename;
	   $counter = $row['Counter'];

// Add 1 to the counter value from the array in $row
$counter += 1;

       $sql2 ="UPDATE tblVideos SET Counter='$counter' WHERE ID = '$id'";
       $result2 = mysql_query($sql2) or die('Query failed. ' . mysql_error());
		
           $file_extension = strtolower(substr(strrchr($filename,"."),1)); 

           switch ($file_extension) { 
               case "wmv": $ctype="video/x-ms-wmv"; break; 
               default: $ctype="application/force-download"; 
           } 

// required for IE, otherwise Content-disposition is ignored 
if(ini_get('zlib.output_compression')) 
ini_set('zlib.output_compression', 'Off'); 

           header("Pragma: public"); 
           header("Expires: 0"); 
           header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
           header("Cache-Control: private",false); 
           header("Content-Type: video/x-ms-wmv"); 
           header("Content-Type: $ctype"); 
           header("Content-Disposition: attachment; filename=\"".basename($filename)."\";"); 
           header("Content-Transfer-Encoding: binary"); 
           header("Content-Length: ".@filesize($filename)); 
           set_time_limit(0); 
           @readfile("$fileurl") or die("File not found."); 

} 



 //Close sql Connection
mysql_close($conn);

?>
Thanks greatly in advance!
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:04 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.