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
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??

Link to comment
Share on other sites

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. ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.