Reply to Re: Two mysql connections

Your name:

Reply:


Posted by elyob on 06/14/06 00:26

"Gordon Burditt" <gordonb.gyj55@burditt.org> wrote in message
news:128ul74nrkva8a8@corp.supernews.com...
> >Not really tried going two ways at once, but I have an include_once
>>connection to a mysql_database, now I need to retrieve info from a second
>>mysql_database ..
>
> Connections aren't include_once. You may be including the code to make
> the connection with include_once, but that doesn't affect the connection.
>
>>My mysql_connects are getting confused. So, (I've had a couple of beers),
>>am
>>I opening up too many at once?
>
> No. I had a page that opened up 3 connections (in this case, on 3
> different servers) to compare the data on the 3 servers. Essentially,
> it was a test for a data migration script (which also involved a
> lot of reorganization) to check if anything got missed. It proved
> very useful. Performance and simultaneous use weren't issues, and
> only I used it.
>
> You should pass the correct connection handle (er, "resource") to
> all of the mysql_* functions to indicate which one you wish to use,
> including mysql_query, mysql_select_db, and functions to fetch
> results. If you don't pass the connection handle, PHP will pick
> one (I forget whether it's the first or the latest), and Murphy's
> law says it gets the wrong one more than 50% of the time.

Firstly, thanks for the really prompt reply!

Okay, this is where I am making a mistake.

I have two files that use the same code ... i.e.

<?php
$dbhost = "server1.com";
$dbname = "server1_dbname";
$dbuser = "server1_dbuser";
$dbpass = "123";

$link=mysql_connect ("$dbhost", "$dbuser", "$dbpass") ;
@mysql_select_db ("$dbname");
?>

I now have a second file called connecttodb.php which has same info, but
different server (i.e. all db stuff is different).

How should I differentiate between the two files when doing calling the
database? i.e. should I call SELECT * FROM file1.tablename etc?

Thanks

Nick

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация