Quick question

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Quick question

Post by Archy »

What would be the ideal way to access a database and update information from an external site that does not allow PHP?

Any ideas to if this can even be done.
(ie, a hit counter, how do they do it?)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have the external site reference a script that supplies the data, and use that script to do the hit count addition.

For instance, you want to hit count an image. So you give them a link that's an image output script. It reads the data asked for, and dumps out the proper image headers and binary data. It also updates the database that someone requested said image.
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

How would I even begin to implament that?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

make a script that can output an image as a downloadable: [devnet]+force +download[/devnet] I think should find a few threads about that aspect.
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

Hmmm, I had a look, but couldnt find any similar topics : (
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

All of those links I looked through previously, and couldnt see how they were relevent, they were mainly asking about how to increment download numbers.

Although this might be (and probably is) what I need, I still dont know how to implament it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

only 1, one was about hit counting in a download script.
Archy
Forum Contributor
Posts: 129
Joined: Fri Jun 18, 2004 2:25 pm
Location: USA

Post by Archy »

Yes, but 6, six were about forcing a download which I dont see how that would help a ticker in a database from incrementing :\
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

...six for the Dwarf-lords in their halls of stone,
Nine for Mortal Men doomed to die,
One for the Remote Lord on his dark Server...

edit: the numbers, its the numbers that got me. ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the threads I linked to were to help you start the implementation, by helping you create a script where you can output an image... once you have that, you just need to add the hit counting database query, which is pie.
AngusL
Forum Contributor
Posts: 155
Joined: Fri Aug 20, 2004 4:28 am
Location: Falkirk, Scotland

Post by AngusL »

Code: Select all

<?php
echo ( readfile ("URL to file here") )
header ("Content-type: Image/whatever format you want, eg jpg, gif, png")

//Database stuff here
?>
Should be a start for you
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

AngusL wrote:

Code: Select all

<?php
echo ( readfile ("URL to file here") )
header ("Content-type: Image/whatever format you want, eg jpg, gif, png")

//Database stuff here
?>
Should be a start for you
that'd create a headers already sent error, along with an string'd integer being added to the buffer created.
AngusL
Forum Contributor
Posts: 155
Joined: Fri Aug 20, 2004 4:28 am
Location: Falkirk, Scotland

Post by AngusL »

Okay, way over my head. Sorry to hijack the thread, but quick question - would it then work if the db code was before the echo and header bit? Newbie out.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Have a look at this: viewtopic.php?t=1157
Post Reply