Connect to MySQL : MySQL Connection « MySQL Database « PHP






Connect to MySQL

<?
$connection = @mysql_connect("mysql153.secureserver.net", "java2s", "password") or die(mysql_error());

$dbs = @mysql_list_dbs($connection)or die(mysql_error());
$db_list ="<ul>";
$i =0;

while ($i < mysql_num_rows($dbs)){
     $db_names[$i] = mysql_tablename($dbs,$i);
     $db_list .= "<li>$db_names[$i]";
     $i++;
}
$db_list .="</ul>";
?>

<HTML>
<HEAD>
<TITLE>MySQL Databases</TITLE>
</HEAD>
<BODY>
<P><strong>Databases on localhost</strong>:</P>
<? echo "$db_list"; ?>
</BODY>
</HTML>

           
       








Related examples in the same category

1.Connect To MySQL Database
2.Listing the Databases Available in a Connection
3.Opening a Connection and Selecting a Database