Jump to content


Photo

way to execute a php file from another file?


  • This topic is locked This topic is locked
11 replies to this topic

#1 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 03 August 2006 - 06:14 AM

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

#2 manmadareddy

manmadareddy
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 03 August 2006 - 06:28 AM

you can do this using curl functions or xmlhttp request


#3 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 01:44 AM

is there another easy way to do this?

I just want
if($var == 1){
  //execute some php file somewhere (NOT include it)
}else{
  //nothing
}


#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 04 August 2006 - 01:46 AM

use eval.

http://www.php.net/eval

#5 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 01:49 AM

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

#6 nethnet

nethnet
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts
  • LocationPhiladelphia, PA, USA

Posted 04 August 2006 - 01:55 AM

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.
"Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep."  --Scott Adams

Current project: nethnet.com

#7 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:10 AM

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.

#8 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:12 AM

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?

#9 nethnet

nethnet
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts
  • LocationPhiladelphia, PA, USA

Posted 04 August 2006 - 02:27 AM

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...
"Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep."  --Scott Adams

Current project: nethnet.com

#10 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:32 AM

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 :)

#11 nethnet

nethnet
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts
  • LocationPhiladelphia, PA, USA

Posted 04 August 2006 - 02:36 AM

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.
"Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep."  --Scott Adams

Current project: nethnet.com

#12 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:37 AM

True, rather than have someone read all this, ill just lock this one and create a new one




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users