下面这个问题纠缠小弟几天了,就是搞不定,请大侠们帮帮我,在此谢过.
这段代码的目的是显示students数据库中所有表格;但是只有在去掉/*  */这
段代码后才执行正确,否则老出现"Parse error: parse error in d:\inetpub\wwwroot\111.php on line 53"
这样的错误(53是最后一行),不知为什么.连接MySQL数据库"students"没问题.<?php
function show_msg($message) //显示信息
{
 echo '<table><tr><td>';
 echo "$message";
 echo '</td></tr></table>';
}
function show_title($title)  //显示标题栏
{
 echo '<html><head><title>';
 echo "$title";
 echo '</title></head><body>';
}
function show_foot()
{
 echo'</body></html>';
}
function show_tables($dbname)     //  显示一个数据库中的所有表格
 {$tables=@mysql_list_tables($dbname);
  $num_tables=@mysql_num_rows($tables);
/*   
if(!$num_tables)
  {
   show_msg("数据库现在没有任何列表.");
   }
   else
   {show_msg("数据库".$dbname."现有如下列表:");
*/
    $i=0;
    echo '<table border=2><tr>';
    while($i<$num_tables)
    {
    $table=@mysql_tablename($tables,$i);
    echo '<table border=2><tr>';
    while($i<$num_tables)
    {$table=@mysql_tablename($tables,$i);
    echo '<td>'.$table.'</td>';
    if($i%3==2)
     echo '</tr><tr>';
    $i++;
    }
    echo '</tr></table>';
  }
  }
?>
<?php
$hostname = 'localhost';
$username = 'zhangfan';
$password = 'study';
$link_id=@mysql_connect($hostname,$username,$password);
show_title("列表");
show_tables("students");
show_foot();
?>

解决方案 »

  1.   

    函数少个结尾的大括号……
    function show_tables($dbname)     //  显示一个数据库中的所有表格
     {$tables=@mysql_list_tables($dbname);
      $num_tables=@mysql_num_rows($tables);
    /*   
      

  2.   

    /*   
    if(!$num_tables)
      {
       show_msg("数据库现在没有任何列表.");
       }
       else
       {show_msg("数据库".$dbname."现有如下列表:");
    */
    那个else少了一个}。