Jump to content

way to execute a php file from another file?


bpops

Recommended Posts

Is there a way to execute a php file from another file?

I do NOT want to include it such as in include(whatever.php);, for I believe this would defeat the purpose.

Is there a way just to execute another php file for say, running a mysql query (for which I need no returns)?

thanks
Link to comment
Share on other sites

I will give this a try, though I don't think this is exactly what I'm looking for. I want to evaluate a separate php file... or maybe I just don't understand this function well enough.

thanks for the reply
Link to comment
Share on other sites

I just have to ask... what is the function of this page you want executed which including it would defeat?  Perhaps if you get a little more specific with your situation it will be easier for us to give you a useful response.
Link to comment
Share on other sites

Well I don't think you'll believe me if I say my reason, that's why I've been holding back.

All week long I've been trying to implement a counter on my website that checks a cookie to see if you're just refreshing or not. (so I'm counting unique views).
Well I have this problem that every so often, it increments, then if I check the count later, it has incremented AGAIN by itself (i can actually run a check in php through mysql, use the sleep(3); function, then have it run the same check, and it is different).

It's not crawlers, or other users. Ive actually finally figured out what the problem is (though I still have no idea how).. Google Ads. If I remove them, everything works fine.
But with them, somehow this mysql query code gets  hijacked. So I want the mysql code in a different file altogether, so theres no chance that the ads disturbs it.

I know this sounds crazy, but I've spent hours upon hours with this problem and I'm sure it's the google ads.
Link to comment
Share on other sites

wow.. as writing my last post I think I figured it out...

Google is checking out my page when that ad loads... and they're incrementing the counter, huh?

so I guess running the php file separately wouldn't work either..


hmmm.. anyone know how to make it so those google ads won't increment my counter?
Link to comment
Share on other sites

I guess they would have to, since their ads are customized to match your page contents.  Here's a couple possible solutions (although I don't think either of them are very practical...)

You could check to see that a Google Spider is running the script instead of, say, a MacOS or Windows user, and based on that data you could tell the counter whether or not to increment.

-- or --

If everytime the page SHOULD increment by one (i.e. someone loads the page) it is actually being incremented TWICE (once by the user, once by the ads), couldn't you just divide the gross total by 2 and have the actual unique count?

Let me reiterate that I don't quite think that either of these solutions is the right way to go, but I can't think of anything else.  There must be a better way to approach it though.  I'm anxious to see what some other members post to this problem...
Link to comment
Share on other sites

Your first approach sounds the most feasible. The second is defenitely not, since the most frustrating thing about the problem is that it is extremely inconsistent. MOST of the time, the counter works right, then maybe 1 in every 5 times, it increments an extra or TWO. (I have two google ads on each page).

But like you said there might be a way of making sure it is a browser looking at the page. There must be a way to do this since many sites do it (as well as trackers), and even phpfreaks here. They have a little counter for each tutorial. That's all I want :)
Link to comment
Share on other sites

It's definitely possible, I just don't know how.  I've never had to use PHP to obtain information like whether or not it's a spider viewing the page, so I don't really know where to begin on that one.

Although, you might consider renaming the topic since that doesn't really apply to your situation anymore.  You might be able to attract someone who knows what to do that way.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.