title: Joining Tables from different Database
body: <p>I am trying to fetch data from two tables in two different database in a same server.
  I am using this code</p>
  
  <pre><code>&lt;?php
  
      $host='localhost';
      $root='root';
      $password='mypass';
      $db=mysql_connect($host,$root,$password) or die('unable to connect database');
      $dbname='BUSMSTR_10';
      mysql_select_db($dbname,$db) or die(mysql_error($db));
  
      $db2=mysql_connect($host,$root,$password) or die('unable to connect database');
      $dbname='BULIB_Info';
      mysql_select_db($dbname,$db2) or die(mysql_error($db2));
  
      $sql="SELECT 
          m_Student.Stud_Name_Form AS Stud_Name_Form,
          m_Student.Enrl_no AS Enrl_no,
          m_Subject.Sub_name AS Sub_name
      FROM 
          BUSMSTR_05.m_Student m_Student
      INNER JOIN
          BULIB_Info.m_Subject m_Subject
      ON
          m_Student.Sub_ID=m_Subject.Sub_ID
  
      LIMIT 10";
  
  $rs=mysql_query($sql);
  
      while($row=mysql_fetch_assoc($rs)){
          echo $row['Stud_Name_Form']."|||||".$row['Enrl_no']."|||||".$row['Sub_name']."&lt;BR&gt;";
          }
  </code></pre>
  
  <p>?></p>
  
  <p>But I am getting error.
  whats wrong with it....
  and how will I fix this??</p>
  
  <p>Error msg----</p>
  
  <pre><code>Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/budcc/html/student/PHP/Student.php  on line 25
  </code></pre>