PHP lists two methods of all tables in the MySQL database

Source: Internet
Author: User
Tags deprecated mysql tutorial php code php tutorial

PHP Tutorial Listing Two methods of all tables in the MySQL database tutorial

The PHP code is as follows:

function List_tables ($database)
{
$rs = MySQL Tutorial _list_tables ($database);
$tables = Array ();
while ($row = Mysql_fetch_row ($rs)) {
$tables [] = $row [0];
}
Mysql_free_result ($RS);
return $tables;
}

However, because the Mysql_list_tables method is obsolete, running the above program gives you a method-outdated hint, as follows:

Deprecated:function mysql_list_tables () is deprecated in ... on line xxx

One way to do this is to set up error_reporting in php.ini, without displaying method-outdated prompts

1 error_reporting = e_all & ~e_notice & ~e_deprecated

Another approach is to use the alternative PHP official recommendation:

function List_tables ($database)
{
    $rs = mysql_query ("Show tables from $data Base ");
    $tables = Array ();
    while ($row = Mysql_fetch_row ($rs)) {
        $tables [] = $row [0];
   }
    mysql_free_result ($RS);
    return $tables; 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.