Jump to content

Connect To Database That Isnt Host


computermax2328

Recommended Posts

Hello All,

 

I haven't been here in a while. It has been a busy semester. Haven't gotten a lot of time to practice coding in a while, but this question did cross my mind this morning for a project I am working on.

 

Is there a way to connect to a database that is not the host. For example, say I was to create a blog with PHP and I gave that system to multiple users, but I wanted to collect all of the posts from all of the blogs in my database. So each blog has it's own database and different hosts, but I have my own that collects all of the posts and content.

 

Any ideas??

 

Thanks! :thumb-up:

Link to comment
https://forums.phpfreaks.com/topic/271544-connect-to-database-that-isnt-host/
Share on other sites

I was just using a blog as an example.

 

Well would it be easier to query your own database and build off of that or query their database and build off of theirs. For example, if there are 3 blogs, blog 1, blog 2 and my blog and blog 1 and 2 are their own unique content and I wanted my blog to be content from both of their blogs. But remember that the blogs they are using are a part of a system that I built for them.

 

I would prefer to query my own database and connect to their database, but what if they are using another host??

 

Is this making sense??

Just like you'd set up any other connection, just replace "localhost" with the IP-address of the host in question.

I do recommend using MySQLI or PDO for this, so that you have a specific object for each DB connection. In addition to all the other reasons you should be using them. ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.