• Resolved idreia

    (@idreia)


    I have a test and production environment. The production is configured as a single user and the test has the network features turned on.

    Strange thing just happened. When moving code from my test system to production, I received a table not found error when making an SQL call via $wpdb. Funny thing is I can see the table, access the table and mySQL tells me the table is OK. So why would code that works on the test system fail on a production system?

    This table is being accessed via a plugin that I wrote. Here is the error from $wpdb:

    WP Database:wpdb Object
    (
        [show_errors] =>
        [suppress_errors] =>
        [last_error] => Table 'mlearn_wrdp1.wp_mlgw_twitterfollowing' doesn't exist
        [num_queries] => 19
        [num_rows] => 14
        [rows_affected] => 0
        [insert_id] => 0
        [last_query] => SELECT * FROM wp_mlgw_twitterfollowing WHERE tw_ID = 14516910
        [last_result] => Array
    ...

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter idreia

    (@idreia)

    I have been looking at this all afternoon and still cannot see why the code works on one machine and fails on the other. The database name is valid, the table exists, all other tables are working… So why all of a sudden would WordPress report the table does not exist?

    I have turned on debug in WordPress and do not see anything unusual…

    This makes me think that the table became corrupted somehow…

    Any other ideas on things I might try?

    In all other cases this is a functioning WordPress site. It is just this table that seems to be missing–even though it is created and has data within.

    Thread Starter idreia

    (@idreia)

    Dropped and recreated the table, no change.

    Have you checked carefully the wp-config.php?

    Thread Starter idreia

    (@idreia)

    No, not sure what I would look for in the config file. This is a working WP site, it is just this one table is not found in the database. And as I have said, the table does exist and is read successfully at other times.

    I wonder, the failure is happening during the dashboard display of a widget that calls wpdb to access the table…since WordPress is able to read the database table at other times this leads me to think it has something to do with the environment setup during a dashboard load.

    Does anyone know of any restrictions for dashboard widgets when it comes to calling $wpdb->get_row?

    Reading from the DB will not affect anything. Its only opening and writing to it.

    Thread Starter idreia

    (@idreia)

    That is what I thought.

    A strange problem… I am convinced this is some obscure issue within the dashboard logic. :-/

    Thread Starter idreia

    (@idreia)

    Just to report back the problem. And it is a bit on the embarrassing side…

    My test system is running MS Vista 64, and my production system is Linux. So guess what, on Vista (and Windows in general) MySQL is case insensitive to table names…and on Linux it is case sensitive. So when I added my new code, for some reason, I camelCased the table name…which meant that it failed on Linux.

    Mystery solved. Just a classic SNAFU from a careless programmer.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Table not found error when it actually IS in the database’ is closed to new replies.