|
Posted by Ninja_Monkey on 02/26/06 20:08
Thanks i used that and it worked. Thanks very much.
Could you explain how this works for me though?
while ($record = mysqli_fetch_array($result, MYSQLI_NUM)) {
echo $record[0], "<br>\r\n";
}
does this style of while loop simply count through the array? im just not
sure how the syntax works?
"NC" <nc@iname.com> wrote in message
news:1140636936.099814.67820@z14g2000cwz.googlegroups.com...
> 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]
|