Page 1 of 1
Possible to select info from DIFFERENT database?
Posted: Sun Aug 26, 2007 9:54 pm
by thefreebielife
Is it possible to use this code to select info from DEF if my config file is set to database ABC?
Code: Select all
$data = mysql_query("SELECT * FROM users WHERE uId='$info'")
Would i have to edit the config file?
Thanks.
Posted: Sun Aug 26, 2007 10:12 pm
by Zoxive
mysql_select_db();
||
Code: Select all
$data = mysql_query("SELECT * FROM db2.users WHERE uId='$info'"
Posted: Mon Aug 27, 2007 7:22 am
by xpgeek
Yes it is possible you can use full path to field name as:
databasename.tablename.fieldname
and You query would be as:
Code: Select all
$data = mysql_query("SELECT * FROM defdb.users u WHERE u.uId='$info'")
Posted: Mon Aug 27, 2007 9:38 pm
by califdon
Assuming that the database is on the same server.
Posted: Tue Aug 28, 2007 3:34 am
by Bon Bon
...And you have the correct access rights for that database.
If not you will have to make 2 different database connections and do 2 differnet database queries and use something like array_multisort to combine them both and sort them how you want them.