• Hi,

    I am trying to publish posts which I have tied to user_Id’s through the wpnameduser plugin, using the script below. The logic behind the simple JOIN seems fine, but in trying to use the following script to publish the current user’s posts on an user specific home page, I get the error message listed at the foot of this email.

    please could someone advise where I am going wrong.

    Thks

    **************************************************************
    <div id=”content” class=”narrowcolumn”>

    <?php

    $querystr = “
    SELECT wposts.*
    FROM $wpdb->posts wposts, $wpdb->prefix . named_users wnamed_users named_users
    WHERE wposts.ID = wnamed_users.post_id
    AND wnamed_users.user_id = ‘$current.user’
    AND wposts.post_status = ‘publish’
    AND wposts.post_type = ‘post’
    AND wposts.post_date < NOW()
    ORDER BY wposts.post_date DESC
    “;

    $pageposts = $wpdb->get_results($querystr, OBJECT);

    ?>
    <?php if ($pageposts): ?>
    <?php foreach ($pageposts as $post): ?>
    <?php setup_postdata($post); ?>

    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”>
    <?php the_title(); ?>
    </h2>
    <small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry ?’); ?>
    </div>

    <p class=”postmetadata”>Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?>
    <?php comments_popup_link(‘No Comments ?’, ‘1 Comment ?’, ‘% Comments ?’); ?></p>
    </div>
    <?php endforeach; ?>

    <?php else : ?>
    <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
    <?php include (TEMPLATEPATH . “/searchform.php”); ?>
    <?php endif; ?>

    </div>
    *******************************
    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 ‘named_users WHERE wposts.ID = wnamed_users.post_id AND wnamed_users.use’ at line 2]
    SELECT wposts.* FROM wp_posts wposts, wp_ . named_users wnamed_users named_users WHERE wposts.ID = wnamed_users.post_id AND wnamed_users.user_id = ‘.user’ AND wposts.post_status = ‘publish’ AND wposts.post_type = ‘post’ AND wposts.post_date < NOW() ORDER BY wposts.post_date DESC

Viewing 1 replies (of 1 total)
  • Thread Starter sam888

    (@sam888)

    apologies_i have seen my simple error!!

    but now getting message that SELECT command denied to me on named_users table.

    would this be a local host issue or is it something to do with the wpnameduser plug in??

    thks

Viewing 1 replies (of 1 total)
  • The topic ‘Syntax error in defining DB table names’ is closed to new replies.