NYCPHP Meetup

NYPHP.org

[nycphp-talk] different sites, one database

Adam Fields fields at hedge.net
Wed Jul 13 11:33:22 EDT 2005


On Wed, Jul 13, 2005 at 12:15:17PM -0300, Henry Ponce wrote:
> Well, now I need to connect to a mysql database on site1.com that holds 
> information that is usefull and needed for most sites. I need to do this on 
> scripts that run on site2.com and site3.com.
> 
> How can I connect to the mysql database on site1.com, when I am running a 
> script on site2.com or site3.com?
> 
> I can't use "localhost" as the server in the mysql_connect() function in the 
> scripts on site2.com or site3.com, because I would be connecting to the mysql 
> database, on each site, which I understand. 

That depends. Are these actually the same database with different
logins? That's probably the case, in which case you >can< use
localhost, and just change the login info.

If they're different databases, you should be able to substitute
"site1.com" or "site2.com" or whatever for "localhost", assuming the
db is set up to listen on ips other than 127.0.0.1 (which it probably
shouldn't be, but probably is).

Do site1.com, site2.com, etc... all resolve to the same IP address?


-- 
				- Adam

** I can fix your database problems: http://www.everylastounce.com/mysql.html **

Blog............... [ http://www.aquick.org/blog ]
Links.............. [ http://del.icio.us/fields ]
Photos............. [ http://www.flickr.com/photos/fields ]
Experience......... [ http://www.adamfields.com/resume.html ]
Product Reviews: .. [ http://www.buyadam.com/blog ]




More information about the talk mailing list