php mysql connection from different sites(host)

I have mysql database on but i want to access this database from another site

I do not know how to connect database like this … i am sure i do not have to use “localhost” but what ?.

Both sites have shared IP address ( do i need to have unique IP address for ?) both sites are hosted on linux server with cpanel.

This is very important to my business please advice me
though i am familiar to php for last few months but hard to me to configure php on server …

looking forward to hearing soon
kindest regards,

Sorry to break your bubble, but coming to a forum like this when you have a business-critical problem is risky at best. You would do good to invest in the knowledge and know-how, or outsource it to a party who already has those features. Furthermore, this sounds like a network issue, rather than a PHP/Database problem.

As for your problem, I’m willing to give it a shot:

On your webserver, you should connect to the IP address or host name of the database server, using the correct port, to connect to the database.

on your database server, you should open up access (ports) in your database engine, your firewall and any routers to allow access to the database from the webserver.

How to connect from remote server: tutorial
I tried lot of things like this:

mysql_connect(“”,$user,$pass) or die (mysql_error());

even used IP addresses , there is an option in cpanel based linux hosting where you can allow access host adding their name server e.g. … but failed

visit to using as a port .

How could I know about my port exactly.

3307 is the default port for MySQL to listen on for incoming connections. You’ll have to set your MySQL account to allow incoming connections from remote hosts too for the user through which you’ll connect.

But again: it’d really be in the best interest of your business if you were to outsource this sort of thing, rather than screwing around by yourself.

Sponsor our Newsletter | Privacy Policy | Terms of Service