views:

31

answers:

1

Beginner help needed :)

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";

<?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 = "<ul>";
$db_num = 0;

//loop through results of functions 
while ($db_num < mysql_num_rows($dbs)) {

//get database names and make each a list point
$db_names[$db_num] = mysql_tablename($dbs, $db_num);
    $db_list .= "<li>$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 = "<ul>";
    $table_num = 0;

//loop through results of function  
    while ($table_num < mysql_num_rows($tables)){
    //get table names and make each bullet point
    $table_names[$table_num] = mysql_tablename($tables, $table_num);
    $table_list .= "<li>$table_names[$table_num]";
    $table_num++;
}

//close inner bullet list and increment number to continue
    $table_list .= "</ul>"
    $db_list .= "$table_list";
    $db_num++;
    }
    //close outer bullet list
    $db_list .= "</ul>";
?>

<html>
<head>
<title>MySQL Tables</title>
</head>
<body>
<p><strong>Data bases and tables on local host</strong></p>

<? echo "$db_list"; ?>

</body>

+2  A: 

missed semicolon?

    $table_list .= "</ul>" <===
    $db_list .= "$table_list";

oraz
perfect, thanks
Jacksta