• Hi

    I am using the $wpdb to carry out SQL queries. I am trying to write a query that will allow me to see all the tables in the database but I keep getting an unknown database error. See code below:

    $sql  = "SHOW TABLES FROM " . '$wpdb';
    if (!$result = mysql_query($sql))
    {
    	die ('Error getting table list (' . $sql . ' :: ' . mysql_error() . ')');
    }
Viewing 1 replies (of 1 total)
  • Shaf,

    Try this query instead:

    $sql = “SHOW TABLES”;

    Your connect string should already connect you to the MySQL DB and you should have a database string which defines which database to act upon. “SHOW TABLES” is a basic sql statement to show all tables in your current database.

    Steve

Viewing 1 replies (of 1 total)
  • The topic ‘SQL Query’ is closed to new replies.