• I recently upgraded to from version 2.0.6 to 2.1 and everything went perfect except my links have disappeared completely. The sidebar section for links now displays the following 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]

    Also, the link options in the control panel have disappeared completely. This seems to be the only issue with the upgrade. Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I had exactly the same problem,and I may have fixed it, but badly. If it helps, some additional info: I am hosted on dreamhost, and the full error message says:

    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

    The problem is in the theme. In my case, the Orchids theme by Sunarayo Hadi. The troublesome command is in sidebar.php.

    I just cut out the relevant bit and pasted in a different way of including links from the ocadia theme, where the entire SQL call block is replaced with the line:

    <?php if (is_home()) { get_links_list(); } ?>

    I found the get_links_list() function in the links.php file in the wp-includes directory. It is a temp fix, because now the links appear but the font style is wrong for the title “blogroll”, so I’ll have to poke around a bit more.

    Aside, I don’t know any PHP or MySQL, this is just hackwork from my programming knowledge from elsewhere… if somebody could post a better fix ??

    rogwei

    (@rogwei)

    The following code snippet fixes this issue. It replaces everything between the Archives li and the Meta li in sidebar.php. The problem was twofold.

    • The SQL select statement referenced the old schema. The old schema had a separate linkcategories table. The new schema has one categories table and a couple of association tables to join posts and links to a category. The new select statement performs the join between the categories and link2cat tables.
    • The call to wp_get_links needed another argument in order to render an HTML li element for each link. Without this argument, the css renders the links as #sidebar ul li instead of #sidebar li ul li. Try saying that three times really fast.
    <?php
     $link_cats = $wpdb->get_results("select distinct cat_id , cat_name from $wpdb->categories c, wp_link2cat l where c.cat_id = l.category_id");
     foreach ($link_cats as $link_cat) {
    ?>
      <li id="linkcat-<?php echo $link_cat->cat_id; ?>"><?php echo $link_cat->cat_name; ?>
       <ul>
        <?php wp_get_links($link_cat->cat_id .'&before=<li>'); ?>
       </ul>
      </li>
    <?php } ?>

    Happy blogging. Roger Weinheimer (72hills)

    Just curious as to why they completely changed the links piece. I actually liked the way it was. I guess there are needs for some but what a pain it was to find the info to fix it and the fact that you can’t change get_links_list so the formating works without forcing the

    • . I spent an hours screwing with the links.php setting before realizing it wasn’t doing it.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Upgrade issue with links’ is closed to new replies.