Remote Counter,

G

Graham Mattingley

Hello Group,

I have been playing with this idea for a month or so, but never really got
anywhere....

I want to make a remote counter image, the same as is found on
mycounter.com, where people have have an IMG SRC on there page which will
increment a SQL counter on my database.

so each time there page is loaded, it get the image from my site, but also
increments a hit counter on SQL..

I have really no idea how to do this, however I need to try and do this is
ASP, not CGI or anything like that, as I will never understand it :)

what I have tryed so far is streaming the image which I can do, but I dont
know how to pass the varable from the IMG SRC to the server..

I know this is not the answer but I want to try and do something like this

how can I pass the for example ?ID=123 value to be grabbed in the page on my
site


<img border="0"
="http://www.mysite.com/counters/index.asp?id=123"> ----------- on remote
site


<============ WITH THIS CODE ON MY SITE======(index.asp)=======>
response.contenttype="image/gif"
response.binarywrite getBinaryFile(server.mappath("../images/car.jpg"))

' ////////// how can I grab the value of the ID on the remote IMG SRC
response.write querystring("id")
' /////////////////////////////////////////////////////////////////////////

function getBinaryFile(fileSpec)

Dim adTypeBinary
adTypeBinary = 1
Dim oStream
set oStream = server.createobject("ADODB.Stream")
oStream.Open
oStream.Type = adTypeBinary
oStream.LoadFromFile fileSpec
getBinaryFile= oStream.read
set oStream=nothing
end function

If I have gone on totally the wrong track, any other ideas would be very
very welcome, as I need to get something running asap..


Kind Regards

Graham Mattingley
 
S

Stuart Palmer

Do it all server side first, then find out the value in your DB and place
that into a variable and use that to display the image.

This may help:-

intCount = 123 'Value from db after it has been incremented
For i = 1 to (6 - (Len(intCount)))
Response.Write ("<img src=""/images/ado/dg0.gif"">")
Next
For i = 1 to Len(intCount)
Response.Write ("<img src=""/images/ado/dg")
Response.Write Mid(intCount, i, 1)
Response.Write (".gif"">")
NEXT

Hope this helps

Stu
 
E

Evertjan.

Graham Mattingley wrote on 31 jan 2004 in
microsoft.public.inetserver.asp.general:
<img border="0"
="http://www.mysite.com/counters/index.asp?id=123"> ----------- on
remote site

src =

Not on a remote site, but just clientside code in an asp or html file on
your site
<============ WITH THIS CODE ON MY SITE======(index.asp)=======>

<%
if request.querystring("id")="123" then
'increment your counter in a database or txt-file
n = getTheNumber("file123")
n = n+1
storeTheNumber("file123",n)
end if
%>
response.contenttype="image/gif"

why, if it is jpeg, specify gif ?
response.binarywrite
getBinaryFile(server.mappath("../images/car.jpg"))

There is a bit more to it, you have to fetch the file, addheader etc.
<>

or you could just do [not tested]:

response.contenttype="image/jpeg"
server.transfer "../images/car.jpg"

or [perhaps]

response.contenttype="image/jpeg" %>
<!--#include virtual="../images/car.jpg" -->

as long as this image has no "<%" in its binary stream,
in wich seldom case you will find that the image is not rendered as
expected. Your response.binarywrite solution is a safer but more coding
intensive solution.
 
S

Steven Burn

If you manage to find a way to do this, I'd love to see it (been trying to
figure it out myself for a couple months and not been able to find anything
useful)

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
S

Steven Burn

I already know how to write a local one, just not one that supports multiple
remote clients.

I'll give the a looksee though and see if they help..... cheers ;o)

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top