Error converting mysql_list_tables to mysqli_

2

I have a page to download a backup of the MySQL information, but it is giving the following error since I started migrating from mysql_ to mysqli_ :

  

Fatal error: Can not use object of type mysqli as array in /home/.../public_html/biblioteca/backup.php on line 25

Before I had added a , inside the key [, ] but it gave error too.

The error code line is:

$res = mysql_list_tables($mysqli [$dbname]) or die(mysqli_error("erro"));

I was not able to replace mysql_list_tables .

    
asked by anonymous 19.03.2016 / 20:14

1 answer

3

You can not mix functions of the mysql and mysqli libraries.

It turns out that the mysqli library does not have a function directly equivalent to mysql_list_tables , but it's easy to get the listing using a simple query :

  $res = mysqli_query( $conexao, 'SHOW TABLES' );
  while( $row = mysqli_fetch_array($res) ) $tabelas[] = $row[0];

  print_r( $tabelas );
    
19.03.2016 / 23:13