Forums

Sidebar error >> SELECT cat_id, cat_name FROM (7 posts)

  1. rizl
    Member
    Posted 5 years ago #

    Hi i hope someone can help me out with this error in my sidebar, when i upgraded from 1.0.9 to 1.2.1 i found this error where my links (blogroll) should be.

    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 gues the problem is whitin my sidebar.php code. so mabe some one can spot an error in here...

    <div class="right_content">
    <?php $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    foreach ($link_cats as $link_cat) { ?>

    <div class="right_header"><?php echo $link_cat->cat_name; ?></div>
    <div class="right_content">
    <ul style="margin-left:20">
    <?php get_links($link_cat->cat_id, '<li class="li3">', '', ' ', FALSE, 'id', TRUE, TRUE, -1, TRUE); ?>
    </div>

    i tried about everything myselfe, but i gues i´m not that good with php and this kind of errors, hope someone can help me out with this problem...
    regards rizl

  2. drmike
    Member
    Posted 5 years ago #

    Please review the codex as some of the template tags have been changed

    Template_Tags

  3. Otto
    Tech Ninja
    Posted 5 years ago #

    The error is that your code is no longer valid with WordPress 2.1 and up. Change it to use the new wp_list_bookmarks function instead.

  4. rizl
    Member
    Posted 5 years ago #

    Thank you verry much Otto42 that worked out just fine.
    seems i´m heaving some other trouwbles instead :(
    the layout is all messed up when clicking on the comments or the <MORE> tag :(
    and the (blogroll) links are not showing up when viewing a post aswell...

    anyhow the main page itselfe is working as i should! thanx again

  5. pkawal
    Member
    Posted 4 years ago #

    I had the same problem and found with my version of wordpress the command linkcategories was not working. The code worked fine when I looked into mySQL database and decided to try dropping the link from it altogether like this:

    <?php
    $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->categories");
    foreach ($link_cats as $link_cat) {
    ?>

    My blogroll and everything showed up as well. Hopes this helps others with this problem :)

  6. MichaelH
    Volunteer
    Posted 4 years ago #

    Remember, wp_categories contains categories for links AND posts.

    Otto42's suggestion to use wp_list_bookmarks is the recommended approach to this problem.

  7. gvaldes
    Member
    Posted 4 years ago #

    It solved It for me:
    $link_cats = $wpdb->get_results("SELECT wp_terms.term_id, name FROM wp_terms LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id WHERE wp_term_taxonomy.taxonomy = 'category'");

Topic Closed

This topic has been closed to new replies.

About this Topic