• I had been using a template that did not use any of the normal WordPress sidebar features and manually set all links, so I never knew about this until today. Recently, my page ended up getting automatically blocked in China (somehow due to my template) and changing my template fixed the problem. However, every template I try, even the WordPress default, shows endless SQL errors for every sidebar field save “search.”

    The strange part about this is, the rest of the site works perfectly. All the links open fine, things show what they are supposed to, and the only other error is an ob_start message at the top courtesy of my server’s PHP running on paranoia settings.

    You can check the page yourself at http://www.cinnamonpirate.com/. It seems to me that somehow $wpdb does not even exist despite it being pulled into the sidebar functions with a global command. If you look at the exact SQL error, it dies because things it depends on from $wpdb are not present for the query.

    I already wiped out my original files and replaced them with the WordPress 1.5.2 release on this site, just in case one of my changes was responsible.

    The errors are:

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE link_visible = ‘Y’ ORDER BY link_name ASC’ at line 4]
    SELECT link_url, link_name, link_image, link_target, link_description, link_rating, link_rel , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated , UNIX_TIMESTAMP(link_updated) AS link_updated_f FROM WHERE link_visible = ‘Y’ ORDER BY link_name ASC

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE post_status = ‘static’ ORDER BY post_title ASC’ at line 1]
    SELECT * FROM WHERE post_status = ‘static’ ORDER BY post_title ASC

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE cat_ID > 0 ORDER BY cat_ID asc’ at line 3]
    SELECT cat_ID, cat_name, category_nicename, category_description, category_parent FROM WHERE cat_ID > 0 ORDER BY cat_ID asc

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) AS cat_count FROM INNER JOIN ON (cat_ID = category_id) ]
    SELECT cat_ID, COUNT(.post_id) AS cat_count FROM INNER JOIN ON (cat_ID = category_id) INNER JOIN ON (ID = post_id) WHERE post_status = ‘publish’ AND post_date_gmt < ‘2005-11-09 13:50:52’ GROUP BY category_id

    Warning: Invalid argument supplied for foreach() in /home/virtual/site19/fst/var/www/html/wp-includes/template-functions-category.php on line 311

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE post_date < ‘2005-11-09 09:50:52’ AND post_status = ‘publi]
    SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM WHERE post_date < ‘2005-11-09 09:50:52’ AND post_status = ‘publish’ GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC

Viewing 5 replies - 1 through 5 (of 5 total)
  • wiped out my original files and replaced them with the WordPress 1.5.2 release
    Did you run the upgrade.php after uploading the new files?

    Thread Starter d-xiansheng

    (@d-xiansheng)

    Yes, I also repaired my tables (not that there were any errors) and optimized them in phpMyAdmin.

    I can spot the error in the SQL (no table in the FROM clause), but I don’t think that bit of information is going to help you much.

    Thread Starter d-xiansheng

    (@d-xiansheng)

    Vaam: I tracked down the line in the actual code, and the problem is that somehow, the $wpdb variable is never entering the function even though it is brought in through “global $wpdb”. The result is, the SQL query ends up like swiss cheese because all the variables depending on having $wpdb get left out …

    This seems like something that has to be caused by paranoid setting of something in the PHP config file, but I can’t begin to guess what because nothing should interfere with variable passing as basic as “global.”

    🙁

    Want some real insanity? Check out http://www.cinnamonpirate.com/index.php?s=jackdaws&submit=Search Every page on the site displays an error in the SQL sidebar, even successful searches. However, if you search for a term that doesn’t exist, magically the sidebar works. And then it goes back to failing miserably …

    Thread Starter d-xiansheng

    (@d-xiansheng)

    I fixed it. Hopefully no one minds the double-post but I figured since this is a solution it would be a good idea.

    The reason why the failed search was exempted is because add_filter(‘the_content’) additions are not performed on it. Through the legacy my_hacks.php file, I had a plugin for porcessing Coppermine image galleries. One of its first lines was to change $wpdb to the table prefix for the Coppermine gallery. At the end, it was supposed to revert back to the original WordPress ones, but for some reason, it did not (possibly it was written for WordPress 1.2 and some DEFINE names have changed since then).

    The solution, which should be obvious, was to just have it create a new $cpgdb variable using the wpdb class, and run all its functions through there instead of altering $wpdb. At the end, where it used to restore $wpdb, I just made it detroy $cpgdb.

    Everything is working fine now. I think previously, I processed my sidebar before processing the body of the site, so I never saw this error.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sidebar is nothing but SQL errors’ is closed to new replies.