[PHP3.12] How do I connect to another database on another server from my PHP script?

A connection is made to a database with the usual statement:

mysql_connect('localhost','USERNAME','PASSWORD');

Where 'localhost' is the database on the same web server as the PHP script.

If you want to connect to a database to another web server you would replace localhost' to that of the IP address of the web server.

The web server where a database resides can be found by moving your mouse over the "Go" link for the Temp Web Address or clicking the link so the IP is displayed in the browser address bar, within the Hosting cPanel v7.5 control panel.

Was this answer helpful?

 Print this Article

Also Read

[PHP3.13] Mime magic is not enabled

To enable mime magic, add the following to your php.ini file:mime_magic.magicfile =...

[PHP3.14] Can I change php.ini settings under my Windows hosting account?

You can put a php.ini file in your FTP directory root (below the public_html directory) otherwise...

[PHP3.16] How are PHP4 and PHP5 set up?

The default PHP version on our webservers is version 5. This is how the PHP setup on our servers...

[PHP3.15] How do I edit php.ini (PHP settings) for my hosting package?

Becuase of the way in which we run PHP, you are able to customise its behaviour with php.ini...

[PHP3.17] Using PHP5 makes all my products disappear in OSCommerce

We have updated our version of php so the default used is PHP5 rather than PHP4. This can cause...