472,783 Members | 967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

Including a .php file from another server?

I am trying to include a function in a .php file on a different server from
the main .php files.

I am using:

include_path=http://www.anotherserver.com/foldername;
include(http://www.anotherserver.com/foldern...letocall.inc);

The .inc file is php formatted. Variables are passed to it (not via GET or
POST though) and returned using return(variablenames, etc);

But for some reason it doesn't appear to work properly.

Am I correct in using the .inc extension?
Are the commands above correctly written?

Basically I am trying to use the fsockopen function in a .php file on
another server where I know it works and return the results to a server
where the fsockopen command doesn't work.

Any help or guidance would be greatly appreciated.
TIA
h
Sep 25 '05 #1
5 2249
hntgzr wrote:
I am trying to include a function in a .php file on a different server from
the main .php files.

I am using:

include_path=http://www.anotherserver.com/foldername;
include(http://www.anotherserver.com/foldern...letocall.inc);

The .inc file is php formatted. Variables are passed to it (not via GET or
POST though) and returned using return(variablenames, etc);

But for some reason it doesn't appear to work properly.

Am I correct in using the .inc extension?
Are the commands above correctly written?

Basically I am trying to use the fsockopen function in a .php file on
another server where I know it works and return the results to a server
where the fsockopen command doesn't work.

Any help or guidance would be greatly appreciated.
TIA
h


When you access your php file this way, it has already been parsed by
the web server. It's just like accessing it from your browser.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 25 '05 #2
>I am trying to include a function in a .php file on a different server from
the main .php files.
When you fetch a PHP file from a remote server, that server processes it
and sends out the OUTPUT (not the PHP code) from the file. I don't
know how Apache on the server you are trying to fetch from deals
with .inc files as opposed to .php files.

Here's an idea: why don't you COPY phpfiletocall.inc to the local
server and use it there?
include_path=http://www.anotherserver.com/foldername;
include(http://www.anotherserver.com/foldern...letocall.inc);

The .inc file is php formatted. Variables are passed to it (not via GET or
POST though) and returned using return(variablenames, etc);
If you were expecting to *RUN* phpfiletocall.inc on www.anotherserver.com,
how do you pass variables to it by other than via $_GET or $_POST?
But for some reason it doesn't appear to work properly.

Am I correct in using the .inc extension?
Are the commands above correctly written?

Basically I am trying to use the fsockopen function in a .php file on
another server where I know it works and return the results to a server
where the fsockopen command doesn't work.


If you are using 'include', you are fetching code from a server
where fsockopen will work (but you're not running it there) and
attempting to use it on a server where it won't work (but that's
where you're trying to make it work), if I understand your problem
correctly.

Gordon L. Burditt
Sep 25 '05 #3

"Gordon Burditt" <go***********@burditt.org> wrote in message
news:11************@corp.supernews.com...
I am trying to include a function in a .php file on a different server
from
the main .php files.


When you fetch a PHP file from a remote server, that server processes it
and sends out the OUTPUT (not the PHP code) from the file. I don't
know how Apache on the server you are trying to fetch from deals
with .inc files as opposed to .php files.

Here's an idea: why don't you COPY phpfiletocall.inc to the local
server and use it there?
include_path=http://www.anotherserver.com/foldername;
include(http://www.anotherserver.com/foldern...letocall.inc);

The .inc file is php formatted. Variables are passed to it (not via GET
or
POST though) and returned using return(variablenames, etc);


If you were expecting to *RUN* phpfiletocall.inc on www.anotherserver.com,
how do you pass variables to it by other than via $_GET or $_POST?
But for some reason it doesn't appear to work properly.

Am I correct in using the .inc extension?
Are the commands above correctly written?

Basically I am trying to use the fsockopen function in a .php file on
another server where I know it works and return the results to a server
where the fsockopen command doesn't work.


If you are using 'include', you are fetching code from a server
where fsockopen will work (but you're not running it there) and
attempting to use it on a server where it won't work (but that's
where you're trying to make it work), if I understand your problem
correctly.

Gordon L. Burditt


Thanks for the reply.

Yup, you understand my problem correctly :)

I am trying to run code on a server where fsockopen does work from the sites
local server where fsockopen doesn't work.

The code located on the remote server (i think that's the correct
terminology) is:

[This is the announce-connectable.inc file]
---------

<?

$sockres = @fsockopen($ip, $port, $errno, $errstr, 8);

if (!$sockres)
{
$connectable = "no";
// @fclose($sockres);
}

else
{
$connectable = "yes";
@fclose($sockres);
}

@return($ip, $port, $errno, $errstr);

?>

---------

The php file on the local server that's calling it is using:
include_path="http://www.anotherserver.com/folder";

include("http://www.anotherserver.com/folder/announce-connectable.inc");
Included in that file are the variables $ip and $port. $errno and $errstr
are not passed to the .inc file as they should always be null prior to be
returned.

Am I trying to do something that PHP can't do?

TIA
h
Sep 25 '05 #4

"Gordon Burditt" <go***********@burditt.org> wrote in message
news:11************@corp.supernews.com...
I am trying to include a function in a .php file on a different server
from
the main .php files.


When you fetch a PHP file from a remote server, that server processes it
and sends out the OUTPUT (not the PHP code) from the file. I don't
know how Apache on the server you are trying to fetch from deals
with .inc files as opposed to .php files.

Here's an idea: why don't you COPY phpfiletocall.inc to the local
server and use it there?


Because the command fsockopen doesn't work on the local server.
include_path=http://www.anotherserver.com/foldername;
include(http://www.anotherserver.com/foldern...letocall.inc);

The .inc file is php formatted. Variables are passed to it (not via GET
or
POST though) and returned using return(variablenames, etc);


If you were expecting to *RUN* phpfiletocall.inc on www.anotherserver.com,
how do you pass variables to it by other than via $_GET or $_POST?


I thought the variables would pass to it anyway. I'm not an expert in PHP
and go only by the guidance on php.net! I've not programmed since the late
80's, so I'm a little out of touch, lol!

If I pass the variables in the URL as ?ip=$ip&port=$port would that work?

As an alternative, I could try calling a function written in CGI, but again,
I am stumped as to how to call a CGI function from a PHP file and have the
results returned!

TIA
h
Sep 25 '05 #5
If you want to run the included code on your server (like access a db
or files on the including server with this included script) you could
try a non standard ext. so, try including
anotherserver.com/includedscript.blah. The disadvantage here is that
someone could access www.anotherserver.com/includedscript.blah and see
your code, so you cant have anything secret on it. You might work
around this by using .htaccess on anotherserver.com to allow this
script only from your including server...but, I really dont know the
ins and outs of doing that.

--
juglesh

Sep 25 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Nick Messick | last post by:
I'm trying to modify a banner display function so it can be including on remote websites. If I just include the file from a remote website the code isn't executed before it is put into the page. ...
4
by: Ralf Koms | last post by:
Hi, I would like to reference some other HTML files within an "main" HTML file (within the "header"), Something like this: <link rel="part1" href="file1.htm"> <link rel="part2"...
5
by: mayamorning123 | last post by:
A comparison among six VSS remote tools including SourceOffSite , SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET To view the full article, please visit...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
3
by: Will Chamberlain | last post by:
For the next couple of months I am hosting 2 domains with one host (Brinkster). What I have done is setup a page called default.aspx and a select case for SiteNameURL = ...
4
by: dar_imiro | last post by:
Hi, I'm trying to get rid of frames as menu holder in my html-page. I'd also like to separate the menu structure to xml and xslt. Also the actual content is divided to xml and its corresponding...
1
by: Martin Mücke | last post by:
I got a website consisting of about 150 php pages. The site uses a frameless table based design. Header and menu are always the same and therefore should be extracted. At the moment I got a...
38
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a ...
20
by: Johan | last post by:
How can I include one XML file into another XML file (on the client side, in Firefox)? I think XInclude is just what I need, but Firefox doesn't support it:...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.