php mysql connection from different sites(host)


#1

I have mysql database on http://www.ravedir.com but i want to access this database from another site http://www.ravehealthdirectory.com

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 http://www.ravedir.com ?) 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,
amit


#2

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.


#3

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

mysql_connect(“ravedir.com:2082”,$user,$pass) or die (mysql_error());
$query=mysql_select_db($database);
mysql_query($query);

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. ns1.name-services.com … but failed

visit to http://au.php.net/function.mysql-connect using example.com:3307 as a port .

How could I know about my port exactly.


#4

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.