Click here to Skip to main content
12,747,207 members (30,534 online)
Rate this:
Please Sign up or sign in to vote.
See more: PHP
How to allow another websites PHP to access specific data from my site?

Imagine I have two websites, hosted on the same server, but using their own different databases. But, I would like website A to be able to enquire and use in it's PHP code, specific information from website B's database, without knowing the structure, table names, field names etc from B's database.
For instance, could there be functions provided by B that return the requested information to A?

Any suggestions on how to implement something like this?
Posted 30-Sep-12 6:49am
Updated 30-Sep-12 6:50am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First of all, I would question if you have correct global architecture with those two sites. Chances are, you might need to have a Web service used by one site or two sites, if the sites are independent.

The other solution would lack both performance and maintainability. If the site is really a Web site using the database, if is primarily used to generate some human-readable HTTP response in response to some HTTP request. What is good for a human user, is not optimized for the use by some code — you would need to parse the response in order to produce real data again, even though in first place the data was already presented properly when it came from the database adapter.

If — quite unfortunately — this is your only possibility at the moment, you would need to use the techniques of Web scraping:[^].

Please see my recent answer:
How to get info from HTML code[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100