calling a function from another site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alphapp
Forum Newbie
Posts: 1
Joined: Tue Aug 19, 2003 9:26 am
Contact:

calling a function from another site

Post by alphapp »

hi all
i ahve 2 site and i write a function to get some field from DB of site 1 and print it .
i want to show this fields in my next site . i write a php code to call first function :

Code: Select all

<?php 
include "http://76entry.org/script/mtheaders.php"; 
mtheaders(); 
?>
but it return this error :

Code: Select all

Fatal error: Call to undefined function: mtheaders() in /home/wplus/public_html/test/mttest.php on line 8
how can i do this ? and what is wrong ?

thx in advance
ali
User avatar
greenhorn666
Forum Commoner
Posts: 87
Joined: Thu Aug 14, 2003 7:14 am
Location: Brussels, Belgium

Post by greenhorn666 »

Well,
First I am not sure include() handles URLs, but maybe it does...
... Still if *.php files are processed by the preprocessor, you don't get the file included in your script, but the result of the script. Which if this file is only an included file (with class, function definition), it returns nothing!
So you don't get the definition of the function included...

Solution (but that is messy!):
rename the file to be included to some extension that isn't interpreted by the hosting server first (like .inc, as I do for my include files...)

But again, I place my includes in some directory that is not accessible from the outside (like somesite.com/includes for includes and somesite.com/htdocs for public). And if you do so too, you won't get access to your file from another server (client in this case)... :P

Be aware that if there is a passwd or something (like to log on the DB backend) it would be visible by anyone... So you should only allow your other server's IP to be able to access the (not being processed) php include file directory.
Post Reply