Forum Moderators: coopster

Message Too Old, No Replies

Getting Variable values using Remote file include

remote file include

         

NeilsPHP

3:07 am on Apr 12, 2009 (gmt 0)

10+ Year Member



Lets say I have 2 sites on servers A & B.I have database on server A and I want to use it's data on site B.
I am using simple include on site B as:

test.php
<?

$data = file_get_contents("sitename/filename.php");
echo ($data);

?>

but this displays 'all' the data that is being echoed in filename.php.
It will be easier to just place code from filename.php into test.php but I am trying to avoid login details to be placed anywhere else and MUST access databse remotely.

my question :
how can I use only some variable values from filename.php and utilize them as a continuation of test.php ?

I googled around and read about cURL and other packages but seems complicated.Can somebody think of any better way ?

coopster

12:17 pm on Apr 17, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Can you parse out the information you need using regular expressions [php.net]?

NeilsPHP

9:44 pm on Apr 18, 2009 (gmt 0)

10+ Year Member



umm..looked at it but didn't know how it can solve what I wanted to do.In my situation,I have some data on server of website A that I MUST access from server of website B.I found 2 ways to do it :
1.Give user access (userid,pass,Host id of B etc) & let it access the data using normal php scripts..
2.Run these scripts on server of A and let B only get the data it is supposed to get using

<?

$data = file_get_contents("sitename/filename.php");
echo ($data);

?>

but i am running into the problem that this is echoing more data than what I want it to.
I want to be able to select certain data that is stored in variables on A that I should be able to 'pipe' to scripts running on B.
May be that is more explanatory and will get some help.I am just careful to not use method 1 above because of security reasons.
thanks

NeilsPHP

9:45 pm on Apr 18, 2009 (gmt 0)

10+ Year Member



sorry for typo..plz read step 1 above as :

1.Give user access (userid,pass,Host id of A etc) & let it access the data using normal php scripts..