954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

mysq_query on 2 dbs .. ?

I have a problem on mysql_query on using 2 dbs on 1 mysql server.

Please help, and code is;;

<?
$db1[host] = "localhost";
$db1[user] = "abc";
$db1[pass] = "1234";
$db1[db] = "db1";
$db1[dir] = "a/ab";

$db2[host] = "localhost";
$db2[user] = "abc";
$db2[pass] = "1234";
$db2[db] = "db2";
$db2[dir] = "a/cd";

$db[link] = @mysql_connect($db1[host], $db1[user], $db1[pass]) or die("host, user, pass .");
?>

test
Return



my apps
db2 apps



<?
// $db1[dataz]='SELECT no,name FROM control_table order by no';
// $result_db1=mysql_query($db1[dataz]);

$result_db1 = mysql_result(mysql_query("SELECT no,name FROM db1.control_table WHERE 1 LIMIT 1"), 0, 0); // databaseA.tableA.fieldA SELECT!
while($data=mysql_fetch_array($result_db1)) {
?>
> <?=$data[name]?> ";
<?
}
?>



<?
$db2[dataz]='select rpt_num,rpt_id,rpt_name from gb_apps order by rpt_num';
$result_db2=mysql_query($db2[dataz]);
while($data=mysql_fetch_array($result_db2)) {
?>
><?=$data[rpt_name]?> ";
<?
}
?>

I could not see any datas.

hanpedro
Newbie Poster
2 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Please read and follow Paradox814's post at this thread:
http://www.daniweb.com/techtalkforums/thread25821.html

It will show you some basics of running mysql queries in PHP along with how to read the mysql errors. Use the techniques shown to modify how you run your queries. Create a page that only has the problem--nothing else. Keep the chunk you are working on as small as possible. When you get it working, add one step to it, and test again.

If you run into one step that you can't get working, then post here with just enough information to make your question clear. Most people answering posts don't have time to read entire code modules and debug for you.

Enjoy the journey. [img]dani-images/smilies/fiyellow/icon_smile.gif[/img]

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You