Click to See Complete Forum and Search --> : Download counter for asp?


Genixdeae
11-29-2003, 09:26 PM
i did a search and the posts just said find out which dynamic extension you provider provieds(asp, php, ect). well does any one know how to code a download counter in asp? i dont want a link to a program. my server also supports php but the page is already done in asp and i would prefer to not have to recode it to php. any help is appriciated.

simflex
11-30-2003, 07:48 AM
I can help you but first, I need to know your table structure.
I am assuming that you have a table.

Genixdeae
11-30-2003, 04:44 PM
ya im using a table. i dont know if this makes it ne harder or not but its grabbing names from the database then the download link is {maps.map_name} and it is on repeat region. alright table structure::
tabel name:maps_info
columns::
unique id: ID
map_name
map_rating


http://12.231.172.168/clanb/downloads.asp is the url

simflex
11-30-2003, 08:30 PM
what is map_rating?
what data type and definition

Genixdeae
11-30-2003, 10:05 PM
map_rating is (once i enter them) going to b a *. its jus going to b for each map.

simflex
12-01-2003, 08:34 AM
ok then here is the structure I came up with.

ID: unique id (autonumber)
map_name (name of map)
map_file (file containing map_name)
map_rating
downloads int (number of times it has been downloaded)
downloadDate datetime (dates maps are downloaded).
If everything sounds good, we can start coding it.

Genixdeae
12-01-2003, 09:10 AM
arite sounds good cept i dont think we will ned the column map_file cuz i define that in the link in the code which is a href="Ftp://bounderz:es@12.231.172.168/<%=(maps.Fields.Item("map_name").Value)%>.zip" everything else sound good tho =) thnx

simflex
12-01-2003, 07:36 PM
Try this:

<%@ Language=VBScript %>

<%
DIM SQL, strMap_Name, strDate, objRS
strMap_Name = Request("MapName")
strDate = Date()
SQL = "SELECT * FROM map_Info WHERE map_Name = ' " & strMap_Name & " ' AND DateDownloaded = ' " & strDate & " ' ;"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open SQL, objConn, adOpenKeyset, adLockPessimistic, adCmdText

IF objRS.EOF THEN ' add one or remove this piece of code
objRS.AddNew
objRS("map_Name") = Request("MapName")
objRS("Downloads") = 1
objRS("DateDownloaded") = Date()
objRS.Update
ELSE ' otherwise, get a count of what is selected
objRS.MoveFirst
DIM intCount
intCount = objRS("Downloads")
objRS("Downloads") = intCount + 1
objRS.Update
END IF

'what you create, you must destroy
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
<a href="Ftp://bounderz:es@12.231.172.168/<%=(maps.Fields.Item("map_name").Value)%>.zip"</a>
%>

if you like, you can replace < href=ftp://bounderz ....
with this
Response.Redirect("/downloads/" & Request("File"))
and just create a /downloads folder within your root directory and place all of your downloads within it.
Now you can track which items are being downloaded from your website, how often, and how many downloads occur.
Note, if you decide to use the response.redirect, then you need to create a field called file, add to your code and you should be fine.

Hope this atleast gets in 3 quarters near where you need to be.

Genixdeae
12-01-2003, 09:38 PM
when i preview it i get an error
Microsoft VBScript runtime error '800a01a8'

Object required: 'Date()'

/clanb/downloadscount.asp, line 6

i thought that Date() worked but apperantly not....newho thankx for the code im gonna keep playing with it :)

simflex
12-02-2003, 06:59 AM
what line are you getting this error?

Genixdeae
12-02-2003, 09:37 AM
strDate = Date()

thats the line of code that is on line 6.

simflex
12-02-2003, 10:52 AM
Replace this code:
SQL = "SELECT * FROM map_Info WHERE map_Name = ' " & strMap_Name & " ' AND DateDownloaded = ' " & strDate & " ' ;"

with this code:

SQL = "SELECT * FROM map_Info WHERE map_Name = ' " & strMap_Name & " ' AND DateDownloaded = # " & strDate & " # "

or you can just comment out this:

strDate = Date()
and replace this:
SQL = "SELECT * FROM map_Info WHERE map_Name = ' " & strMap_Name & " ' AND DateDownloaded = # " & strDate & " # "

with this:

SQL = "SELECT * FROM map_Info WHERE map_Name = ' " & strMap_Name & " ' AND DateDownloaded = # " & Date() & " # "

One of them should work for you.