Forums

Links give me database error on update to 2.1 (10 posts)

  1. andyh2
    Member
    Posted 1 year ago #

    I'm getting 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

    I'm not sure what it means, and I don't think there is an error in my SQL.

  2. Cheezykins
    Member
    Posted 1 year ago #

    Ive just registered myself because of this problem.

    It would appear that $wpdb->linkcategories is NULL in 2.1, hence breaking any SQL that relies upon it. This doesn't seem to be a documented change so I'm not sure what's causing it. :/

  3. andyh2
    Member
    Posted 1 year ago #

    I also did a fresh install on my computer, and it still gives me the error.

  4. darrenstraight
    Member
    Posted 1 year ago #

    Near enough the same proble here!

    [Unknown column 'cat_2' in 'order clause']
    SELECT * FROM wp_categories WHERE cat_ID > 0 AND link_count > 0 ORDER BY cat_2 ASC

    Could only get <?php get_links_list(); ?> to work but its not what I want I want to choose when and where I want each category:

    <?php wp_get_links(2); ?>
    <?php get_links_list(2); ?>

  5. Cheezykins
    Member
    Posted 1 year ago #

    Ok, it seems they've joined the categories tables together, so a simple fix for me was changing
    $wpdb->get_results('SELECT cat_id, cat_name FROM ' . $wpdb->linkcategories);

    to this

    $wpdb->get_results('SELECT cat_id, cat_name FROM ' . $wpdb->categories . ' WHERE link_count > 0')

  6. andyh2
    Member
    Posted 1 year ago #

    In which file?

  7. Cheezykins
    Member
    Posted 1 year ago #

    whichever file is calling $wpdb->linkcategories, possibly one of your theme files. I was calling it in my theme.

  8. adam8281
    Member
    Posted 1 year ago #

    I had similar problems. I'll describe the problems here, and then my solutions:

    Problem 1) The Links section in my sidebar didn't display properly, but instead there was an SQL error message, similar to the ones listed above

    Problem 2) No categories were appearing in the sidebar under the "Categories" heading, even though the category name WAS appearing next to each of my posts

    --Solutions--

    Solution 1) Edited sidebar.php, taking out get_grouped_links_list and replacing it with wp_list_bookmarks. You might not have "get_grouped_links_list" (I believe it might be exclusive to the theme I use), but you probably have "get_links_list", which is now deprecated and should be replaced by "wp_list_bookmarks" if you're having issues.

    Solution 2)Edited sidebar.php, taking out category_cloud and replacing it with wp_list_categories. You probably won't have the "category_cloud" function in your sidebar unless you are using the "durable" theme, but you might have another category function that doesn't work with wp 2.1, and which you need to replace with "wp_list_categories".

    Hope this helps someone

  9. DJM
    Member
    Posted 1 year ago #

    Thanks Cheezykins, that worked.

  10. StefanoVirgilli
    Member
    Posted 1 year ago #

    Doesn't make sense for me.
    None of my file's named linkcategories or even similar.

    How to solve this problem?

    Steve

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags