Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:50:20+00:00 2026-06-12T16:50:20+00:00

Once a database is created how can it be checked if the database contains

  • 0

Once a database is created how can it be checked if the database contains tables or table structure using PHP?

Scenario:

When the user accesses the system first time it creates a default database with no tables, then in the next step the user is supposed to import the customized database structure by uploading .sql file. I need to check if they have imported the database or has skipped that step by checking if the default database that was automatically created earlier has any table structure.

When I executed mysql_list_tables(defaultDBName) it just returns “Your SQL query has been executed successfully“, but no result set in phpMyAdmin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:50:21+00:00Added an answer on June 12, 2026 at 4:50 pm
    <?php
    $dbname = 'mysql_dbname';
    
    if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
        echo 'Could not connect to mysql';
        exit;
    }
    
    $sql = "SHOW TABLES FROM $dbname";
    $result = mysql_query($sql);
    
    if (!$result) {
        echo "DB Error, could not list tables\n";
        echo 'MySQL Error: ' . mysql_error();
        exit;
    }
    
    while ($row = mysql_fetch_row($result)) {
        echo "Table: {$row[0]}\n";
    }
    
    mysql_free_result($result);
    ?>
    

    from Documentation http://php.net/manual/en/function.mysql-list-tables.php

    You can use if(mysql_num_rows($result) > 0) instead of looping through $result..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created 2 tables in a database, each table has a CompanyID field that's
I created a database using GoDaddy's online database manager, but I can't query it
I've created a login system using PHP sessions. Here's how it works: 1.) when
I have created a registration/login system for my members area. Once the user has
I have an Android Service that accesses the database about once per minute. Is
Once the user is authenticated, I fetch the User information from the Database and
PHP PDO Singleton Class: <?php require_once('app/config.php'); // Require constants HOST, DATABASE, USER, PASSWORD /*
I'm using a JTree that is populated from a database. The tree is created
I have created an app using a badly named database, all alterations to important
I have created a set of Models for my database using Python. Now I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.