|
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
Navigation:
[Reply to this message]
|