[support] Inserting php block snippet into a standard node

Jason Flatt drupal at oadaeh.net
Fri May 4 12:49:39 UTC 2007


On Friday May 4 2007 3:30 am, Neil: esl-lounge.com wrote:
> I am creating a dynamic newsletter using the simplenews module and php
> block snippets. I've got the overall mechanics working well.
>
> I create the newsletter, say /newsletter/05-may-07 which has standard
> header and footer text which goes out to every person. Then my idea is to
> insert location-based content into it so that Jane from Texas sees "Last
> five members from Texas", "Last five posts from Houston", "Five members who
> go to your school" and so on. Chris from London would see different
> content.
>
> The problem I've hit though is that when I insert the block snippet into
> the node, choose PHP as input format and press "Submit", none of the
> content below the snippet shows. Here is my snippet:
>
> <?php
> global $user;
> $result=db_query("SELECT dru_users.uid, dru_users.init FROM dru_users WHERE
> (dru_users.uid = $user->uid)"); while ($u = db_fetch_object($result)) {
> $items[]=l($u->init, "user/" . $u->uid);
> }
> return theme('item_list',$items);
> ?>
>
> This is just a test snippet to test the concept....in a block, it shows the
> current user's e-mail address. It also does this in a node, but as I say,
> the rest of the content below this code doesn't come through.
>
> Any idea what the problem is?

Try it this way:

<?php
  global $user;
  $result=db_query("SELECT uid, init FROM dru_users WHERE dru_users.uid = %s", 
$user->uid);

  while ($u = db_fetch_object($result)) {
    $items[]=l($u->init, "user/" . $u->uid);
  }

  return theme('item_list',$items);
?>

I'm assuming your database tables have a prefix, thus the "dru_" before 
the "users" in the table name.

BTW, sorry about the other post. I meant to close it and sent it instead.

-- 
Jason Flatt
http://www.oadaeh.net/
Father of Six:  http://www.flattfamily.com/ (Joseph, 13; Cramer, 11; Travis, 
9; Angela; Harry, 5; and William, 12:04 am, 12-29-2005)
Linux User:     http://www.kubuntu.org/
Drupal Fanatic: http://drupal.org/


More information about the support mailing list