Jump to content

Archived

This topic is now archived and is closed to further replies.

cody7

include() a file

Recommended Posts

Hi

i have here a file containing all my functions (myfunction.php)

i have created a program on my clients server and i need to use (myfunction.php).

my tendency is to include(http://mydomain.com/myfunction.php);

but if i do this the function inside it will not be valid right?

i can't put myfunction.php to my clients local machine because it contains queries of my tables.

so my question is how will i include() myfunction.php as if im just including a file in his local machine?

hope my question is clear.

Thanks for any help!!!



Share this post


Link to post
Share on other sites
I don't believe you can "include" a PHP file that is located on another server. Your best bet is going to be allowing remote requests to your mysql database.

Share this post


Link to post
Share on other sites
Yes you can do this type of include. I have several clients setup on their site/page/server to include a script from my server, which processes requests to the database and returns what is needed.

This is all I do where I need the script to included.

[code]<?php
include ('http://www.yoursite.com/yourscript.php');
?>[/code]

This works fine and there is no need to allow remote requests my database.

Share this post


Link to post
Share on other sites
here is an exmple

myfunction.php (resides in my server: [a href=\"http://mydomain.com/myfunction.php)\" target=\"_blank\"]http://mydomain.com/myfunction.php)[/a]
[code]
<?

function give_name(){
return "Joe";
}
?>
[/code]


remote.php (resides in my clients server: [a href=\"http://clientdomain.com/remote.php)\" target=\"_blank\"]http://clientdomain.com/remote.php)[/a]

[code]
<?
include("http://mydomain.com/myfunction.php");
echo "NAME = ".give_name();
?>
[/code]


RESULT:

Fatal error: Call to undefined function: give_name() in /home/../../../remote.php on line 2


So idea here is that i can use my function without giving it to my client.

i just want to see

NAME = Joe

as the output


Thanks for any idea you can give me.

[!--quoteo(post=367048:date=Apr 20 2006, 06:55 PM:name=freakus_maximus)--][div class=\'quotetop\']QUOTE(freakus_maximus @ Apr 20 2006, 06:55 PM) [snapback]367048[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Yes you can do this type of include. I have several clients setup on their site/page/server to include a script from my server, which processes requests to the database and returns what is needed.

This is all I do where I need the script to included.

[code]<?php
include ('http://www.yoursite.com/yourscript.php');
?>[/code]

This works fine and there is no need to allow remote requests my database.
[/quote]

Share this post


Link to post
Share on other sites
Well I guess it's going to depend on your function in some way.

But, in the example you gave, you should move your echo to the script on your server. The value that is echoed is what will appear on the client side.

Share this post


Link to post
Share on other sites

×

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.