Variable returns

I’m trying to populate an array with mysql table names from my database. The following code returns:
“Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given”

$db_inst = mysql_select_db($dbname);
        
        $showtablequery = "
	SHOW TABLES
	FROM
	$db_inst
	";
$showtablequery_result	= mysql_query($showtablequery);
while($showtablerow = mysql_fetch_array($showtablequery_result))
{
	echo $showtablerow[0]."<br />";
}

When I remove the variable $db_inst and use $dbname in the query as follows, the code runs fine. I don’t understand why the variable is not returning a string instead of boolean.

mysql_select_db($dbname);
        
        $showtablequery = "
	SHOW TABLES
	FROM
	$dbname
	";
$showtablequery_result	= mysql_query($showtablequery);
while($showtablerow = mysql_fetch_array($showtablequery_result))
{
	echo $showtablerow[0]."<br />";
}

Thanks in advance.

$db_inst = mysql_select_db($dbname);

    $showtablequery = "
SHOW TABLES
FROM
$db_inst
";

mysql_select_db() selects a database, not a table. The function returns true or false depending whether the DB was found and selected into context.

Cheers,
Alex

That makes sense. Thanks.