• 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

    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)
  • wp_list_cats? or something like that. Categories have changed for themes.

    Thread Starter tinggg

    (@tinggg)

    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

    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

    (@tinggg)

    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.

    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?

    Oops. My Bad,

    The theme does have a lot of dependence on the DB and version of WP.

    Thread Starter tinggg

    (@tinggg)

    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

    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

    (@tinggg)

    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 but things just got worse. Can anyone help me update the above code replacing the depreciated tags?

    Thanks

    To display links (from Blogroll) this is the tag you should use:
    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.