Title: WordPress database error after upgrade
Last modified: August 18, 2016

---

# WordPress database error after upgrade

 *  [tinggg](https://wordpress.org/support/users/tinggg/)
 * (@tinggg)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/)
 * hi
 * Just upgraded to 2.2 and i’m having a problem with my custom template. In the
   sidebar – under ‘last comments’ and above ‘meta’ I am setting this error:
 * > 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 ” at line 1]
   >  SELECT cat_id, cat_name FROM
 * [Here’s my sidebar code at pastebin](http://wordpress.pastebin.ca/598270)
 * I’ve searched for a fix and have tried the following that didn’t work:
 * Try 1.
    I replaced:
 * $link_cats = $wpdb->get_results(”SELECT cat_id, cat_name FROM
    $wpdb->linkcategories”);
 * with:
 * $link_cats = $wpdb->get_results(”SELECT cat_id, cat_name FROM
    $wpdb->categories
   WHERE link_count > ‘0′”);
 * Try 2
    I replaced:
 * <?php get_links_list(); ?>
 * with
    <?php wp_list_bookmarks(); ?>
 * Neither of these steps removed the error.
 * Can anyone suggest anything else, your help is appreciated.
 * Thanks

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

 *  [ccoupe](https://wordpress.org/support/users/ccoupe/)
 * (@ccoupe)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588180)
 * wp_list_cats? or something like that. Categories have changed for themes.
 *  Thread Starter [tinggg](https://wordpress.org/support/users/tinggg/)
 * (@tinggg)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588184)
 * > wp_list_cats? or something like that. Categories have changed for themes.
 * …anyone else?
 * I’m not a coder so if I need to replace a line of code I would be grateful if
   you could provide the old code and the new code.
 * Many thanks
 *  [ccoupe](https://wordpress.org/support/users/ccoupe/)
 * (@ccoupe)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588275)
 * I don’t have **your** old code and I’m not going to put up a old wordpress with
   your theme just to show you which line is bad.
 *  Thread Starter [tinggg](https://wordpress.org/support/users/tinggg/)
 * (@tinggg)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588295)
 * ccoup, I provided a link to the code in pastebin – this is the required practice
   on this forum. Giving incomplete feedback like
 * > wp_list_cats? or something like that. Categories have changed for themes.
 *  doesn’t really help at all.
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588307)
 * What I don’t understand: why do you have that complicated code instead of using
   just the template tags that would display your links?
    Any rational explanation?
 *  [ccoupe](https://wordpress.org/support/users/ccoupe/)
 * (@ccoupe)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588316)
 * Oops. My Bad,
 * The theme does have a lot of dependence on the DB and version of WP.
 *  Thread Starter [tinggg](https://wordpress.org/support/users/tinggg/)
 * (@tinggg)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588324)
 * > What I don’t understand: why do you have that complicated code instead of using
   > just the template tags that would display your links?
   >  Any rational explanation?
 * Please take into account that I do not have any knowledge of php or wordpress
   templates – I picked this template up a few years ago and as to the complicated
   code, well I can’t comment, that’s how it came, it all looks complicated to me.
   What should I replace it with? Template tags does not mean much to me – can I
   go somewhere and copy the necessary code?
 * Thanks
 *  [ccoupe](https://wordpress.org/support/users/ccoupe/)
 * (@ccoupe)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588328)
 * The glib answer – pick a new theme that’s more current with today’s WordPress.
   There’s a huge number of them. Some will work better than others but that’s a
   choice you can make and trying one out is harmless to your data and content.
 * There’s a link off of the wordpress.org page that will get you to the theme library
   or a web search will find other theme repositories. Themes are like free puppies.
   Once you have one, it’s yours to take care off until “that time” comes.
 *  Thread Starter [tinggg](https://wordpress.org/support/users/tinggg/)
 * (@tinggg)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588374)
 * ok,
 * i’ve removed the following code from the sidebar and the error has disappeared–
   so it must definately be this piece of code causing the error:
 *     ```
       <?php
        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
        foreach ($link_cats as $link_cat) {
        ?>
         <li id="linkcat-<?php echo $link_cat->cat_id; ?>"><h4><?php echo $link_cat->cat_name; ?></h4>
          <ul>
           <?php wp_get_links($link_cat->cat_id); ?>
          </ul>
         </li>
        <?php } ?>
       ```
   
 * I’ve spent the last three hours trying out different tags from here [http://codex.wordpress.org/Template_Tags](http://codex.wordpress.org/Template_Tags)
   but things just got worse. Can anyone help me update the above code replacing
   the depreciated tags?
 * Thanks
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588390)
 * To display links (from Blogroll) this is the tag you should use:
    [http://codex.wordpress.org/Template_Tags/wp_list_bookmarks](http://codex.wordpress.org/Template_Tags/wp_list_bookmarks)

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

The topic ‘WordPress database error after upgrade’ is closed to new replies.

## Tags

 * [Database Error](https://wordpress.org/support/topic-tag/database-error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 3 participants
 * Last reply from: [moshu](https://wordpress.org/support/users/moshu/)
 * Last activity: [18 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-after-upgrade/#post-588390)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
