title: php and mysql listing databases and looping through results
body: <p>Beginner help needed :)</p>
  
  <p>I am doign an example form a php book which lists tables in databases.
  I am getting an error on line 36: $db_list .= "$table_list";</p>
  
  <pre><code>&lt;?php
  
  //connect to database
  $connection = mysql_connect("localhost", "admin_cantsayno", "cantsayno")
      or die(mysql_error());
  
  //list databases    
  $dbs = @mysql_list_dbs($connection) or die(mysql_error());  
  
  //start first bullet list
  $db_list = "&lt;ul&gt;";
  $db_num = 0;
  
  //loop through results of functions 
  while ($db_num &lt; mysql_num_rows($dbs)) {
  
  //get database names and make each a list point
  $db_names[$db_num] = mysql_tablename($dbs, $db_num);
      $db_list .= "&lt;li&gt;$db_names[$db_num]";
  
  //get table names and make another list
      $tables = @mysql_list_tables($db_names[$db_num]) or die(mysql_error());
      $table_list = "&lt;ul&gt;";
      $table_num = 0;
  
  //loop through results of function  
      while ($table_num &lt; mysql_num_rows($tables)){
      //get table names and make each bullet point
      $table_names[$table_num] = mysql_tablename($tables, $table_num);
      $table_list .= "&lt;li&gt;$table_names[$table_num]";
      $table_num++;
  }
  
  //close inner bullet list and increment number to continue
      $table_list .= "&lt;/ul&gt;"
      $db_list .= "$table_list";
      $db_num++;
      }
      //close outer bullet list
      $db_list .= "&lt;/ul&gt;";
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;MySQL Tables&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;&lt;strong&gt;Data bases and tables on local host&lt;/strong&gt;&lt;/p&gt;
  
  &lt;? echo "$db_list"; ?&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>