Jump to content


Photo

include() a file


  • Please log in to reply
4 replies to this topic

#1 cody7

cody7
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 April 2006 - 11:30 PM

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!!!





#2 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 20 April 2006 - 11:39 PM

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.

#3 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 20 April 2006 - 11:55 PM

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.

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

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

#4 cody7

cody7
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 21 April 2006 - 12:25 AM

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]
<?

function give_name(){
 return "Joe";
}
?>


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

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


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) View Post[/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.

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

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


#5 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 21 April 2006 - 01:56 AM

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users