Geronantimo
Technical User
I have found a useful script that can display the databases on a hosting account.
How could I modify it so that the username and password can be entered into a form to return the results (when there is no ability to modify the script)
How could I modify it so that the username and password can be entered into a form to return the results (when there is no ability to modify the script)
Code:
<?php
// FILENAME: LIST_MYSQL_DBS.PHP
// ----------------------------
define( 'NL', "\n" );
define( 'TB', ' ' );
// connecting to MySQL.
$conn = @mysql_connect( 'localhost', 'username', 'password' )
or die( mysql_errno().': '.mysql_error().NL );
// attempt to get a list of MySQL databases
// already set up in my account. This is done
// using the PHP function: mysql_list_dbs()
$result = mysql_list_dbs( $conn );
// Output the list
echo '<ul>'.NL;
///* USING: mysql_fetch_object()
// ---------------------------
while( $row = mysql_fetch_object( $result ) ):
echo TB.'<li>'.$row->Database.'</li>'.NL;
endwhile;
//*/
/* USING: mysql_fetch_row()
// ------------------------
while( $row = mysql_fetch_row( $result ) ):
echo TB.'<li>'.$row[0].'</li>'.NL;
endwhile;
//*/
/* USING: mysql_fetch_assoc()
// --------------------------
while( $row = mysql_fetch_assoc( $result ) ):
echo TB.'<li>'.$row['Database'].'</li>'.NL;
endwhile;
//*/
echo '</ul>'.NL;
// Free resources / close MySQL Connection
mysql_free_result( $result );
mysql_close( $conn );
?>