0

I'm having trouble displaying results when i connect to 2 databases. My connection script seems to be working fine and returns no errors;

$connect1 = mysql_connect("localhost","user","pass", true);
$connect2 = mysql_connect("localhost","user","pass", true);

$db_selected = mysql_select_db("database1", $connect1);
$db_selected = mysql_select_db("database2", $connect2);

When i run the queries, however, I'm only managing to get the results from database1 and nothing from database2, not even any errors.My query codes look like;

$query = "select * from tableA";
$result = mysql_query($query, $connect1) or die(mysql_error());

$query = "select * from tableB";
$result = mysql_query($query, $connect2) or die(mysql_error());

Have i gone about this the wrong way? Any help or guidance would be greatly appreciated.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by jpknoob
0

You have done absolutely fine work.
I tried, it is working fine.
You may have some connection problem.
Hope you do fine work like this.
Thanks.
My code

<?php
$connect1 = mysql_connect("localhost","root","rootwdp", true);
$connect2 = mysql_connect("localhost","root","rootwdp", true);

$db_selected = mysql_select_db("student", $connect1);
$db_selected = mysql_select_db("login", $connect2);

$query = "select * from emp";
$result = mysql_query($query, $connect1) or die(mysql_error());

echo mysql_num_rows($result).'<br />';

$query = "select * from members";
$result = mysql_query($query, $connect2) or die(mysql_error());
echo mysql_num_rows($result);
?>

Edited by mahavir123: n/a

0

Thanks for the reply. it seems i left a rogue 'where' statement in the code that wasn't supposed to be there, fixed now and it does indeed work!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.