Forums

WordPress database error after upgrade (11 posts)

  1. tinggg
    Member
    Posted 2 years ago #

    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

  2. ccoupe
    Member
    Posted 2 years ago #

    wp_list_cats? or something like that. Categories have changed for themes.

  3. tinggg
    Member
    Posted 2 years ago #

    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

  4. ccoupe
    Member
    Posted 2 years ago #

    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.

  5. tinggg
    Member
    Posted 2 years ago #

    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.

  6. moshu
    Member
    Posted 2 years ago #

    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?

  7. ccoupe
    Member
    Posted 2 years ago #

    Oops. My Bad,

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

  8. tinggg
    Member
    Posted 2 years ago #

    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

  9. ccoupe
    Member
    Posted 2 years ago #

    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.

  10. tinggg
    Member
    Posted 2 years ago #

    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

  11. moshu
    Member
    Posted 2 years ago #

    To display links (from Blogroll) this is the tag you should use:
    http://codex.wordpress.org/Template_Tags/wp_list_bookmarks

Topic Closed

This topic has been closed to new replies.

About this Topic