Reply to Re: Two mysql connections

Your name:

Reply:


Posted by Gordon Burditt on 06/14/06 01:01

><?php
>$dbhost = "server1.com";
>$dbname = "server1_dbname";
>$dbuser = "server1_dbuser";
>$dbpass = "123";
>
>$link=mysql_connect ("$dbhost", "$dbuser", "$dbpass") ;

You see that value $link returned by mysql_connect?
It's a connection handle. Or, if you prefer, a resource link_identifier.

>@mysql_select_db ("$dbname");

You pass the connection handle to functions that use the connection, like:

mysql_select_db("$dbname", $link);

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

Hopefully it assigns to something different from $link (like $link2).

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

$resultset = mysql_query("SELECT * FROM tablename", $link2);

Those optional link_identifier arguments aren't optional in your situation.

Gordon L. Burditt

[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

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