|
Posted by NC on 02/22/06 21:35
Ninja_Monkey wrote:
> ill show you the code im trying.
>
> $connection = mysqli_connect($_SESSION['host'], $_SESSION['user'],
> $_SESSION['pass']);
> $sql = "SHOW DATABASES";
> $result = mysqli_query($connection, $sql);
> $dblist = mysqli_fetch_array($result, MYSQLI_NUM); # A PRINT OF THIS
> SAYS Array
> $c = 0;
> while (count($dblist) > $c) {
> print_r($dblist[$c] . "<br>\n"); #THIS PRINTS OUT AS:
> "information schema". IT ONLY PRINTS 1 aswell.
> $c++;
> }
> $result = NULL;
> @mysqli_free_result($result);
> mysqli_close($connection);
>
> What is an information Schema??? and why does this not work.
Basically, because you think mysqli_fetch_array() returns a list of
databases (it doesn't). A SHOW DATABASES query returns a list of
databases, with each name in its own record. So you need to read
through the result set; something like this:
$connection = mysqli_connect($_SESSION['host'],
$_SESSION['user'], $_SESSION['pass']);
$sql = "SHOW DATABASES";
$result = mysqli_query($connection, $sql);
while ($record = mysqli_fetch_array($result, MYSQLI_NUM)) {
echo $record[0], "<br>\r\n";
}
mysqli_free_result($result);
mysqli_close($connection);
Cheers,
NC
Navigation:
[Reply to this message]
|