--- In [email protected], "Suzi" <[EMAIL PROTECTED]> wrote:
>
> I have several sites that need to use a single database. Each site
is
> on a domain of its on with the database on a separate domain. I
> usually use :
>
> -----
> $connection = mysql_connect("localhost","username","password") or
> die("Couldn't make a connection.");
>
> $db = mysql_select_db("database", $connection)
> or die("Couldn't select database.");
> -----
>
> ...but since the database is not on the "localhost", how do I form
the
> php code to link to an external database?
>
> I have set the external sites as "Access Hosts" on the main site.
What
> do I do to connect these external sites to the main database?
>
> Thanks,
>
> Susan
>
In order to access a remote database, the host of that database needs
to make 2 entries into the mysql database. Those entries will be in
both the 'db' and 'user' tables and include either the IP address or
domain name of the connecting site in the 'host' column of both
tables. When they're done, they need to restart mySQL. If they
changed the default port of 3306 when mySQL was installed, you'll
need to have them tell you what it is.
Then in your connect string, you'll do the following:
$connection = mysql_connect("domain.name:3306","username","password")
or die("Couldn't make a connection.");
- OR -
$connection = mysql_connect("IP.address:3306","username","password")
or die("Couldn't make a connection.");
$db = mysql_select_db("database", $connection)
or die("Couldn't select database.");
I just did that for a client last week and it worked perfectly.
--
Jim
Website Managers
http://www.websitemanagers.net
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/HKFolB/TM
--------------------------------------------------------------------~->
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/