Forum Moderators: coopster
site1 gives data to site2
site2 display data from site1
something that works like rss? (i don't know how to create this kind of script.)
My purpose is to integrate my two websites, the first website will supply the information needed then the second site will diplay the information on certain locations of the site.
I already learned how to read/display/manipulate mysql data if the database is located on the same host (server) but not on a separate host.
please help.
thanks in advance.
What you can do however is use the site1 to process the data and spit it out.
on site2:
<?php
include("www.site1.com/site2.php?search=bla");
?>
on site1 file site2.php:
<?php
$search = mysql_real_escape_string($_GET["search"]);
//connect to db, get the results
//print the results
echo "Results for search string $search are:"<br>
print_r $results;
?>
This is also not the best way, but will work.
Michal Cibor
include 'http://site1.kom/sub1/doit-onsite1.php'
and use the module on site2. it worked.
Since I need to return the value to a variable, I put the codes in a function named getxdata() inside doit-onsite1.php without changing anything on the first module except for the variable that will receive the value. It said:
Call to undefined function: getxdata() in /home/site2/public_html/fetch-site1data.php on line 100
something might be wrong on how I include or call the function on site 2 module?
:( :( :(
$fp = fopen("http://www.site1.com/my_feed.php", "r");
while (!feof($fp)) $content = fgets($fp, 4092);
fclose($fp);
print "$content";
Edit.
Of course remember to chmod the file on site1 so it can be read from site2.
Hope this cleares things for you.
Mogenshoj, your way is the same as include, however include works through apaache on the server there, when fopen may be able to read clear php (not execute it). And you don't want to execute that php here, but there.
Best regards
Michal Cibor
PS. My explanation may get a bit confusing. if so, don't hesitate to write.
thanks, I understand what you said. I tested the function on the same site, it work, but will not on another site.
Mogenshoj :
thanks also, the file was succesfully read on the other site. It was read, not executed.
Here's another idea (just idea, i don't know how to do this)
site1 with call a function to site2 that will create a temporary flat file for the 10 lines of data, then another function from site1 will read the flat file from site2 then load it in an array? (how to put lines in an array?)
comments please?
thanks.
If you read plain db I recommend storing the data in csv format, which is easy to read and write (with implode() [php.net] and [url="httl://www.php.net/explode]explode[/url])
Hope this will help you
Best regards
Michal Cibor