TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 561
  • Total: 561

Top Posters block query

Started by darkangel, May 26, 2012, 09:45:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

darkangel

I have this code installed from this post:

http://www.tinyportal.net/index.php?topic=31670.0


I have had to turn off the block cause it is (after testing blocks) the one that is giving me this error:

[26-May-2012 15:27:31] PHP Parse error:  syntax error, unexpected ',' in Themes/default/TPsubs.template.php(127) : eval()'d code on line 31


I have been getting this error in the admin section but since turning off the block it went away---wait for it---

turned on the block and removed code for avatars to show, and it still works but even though the error is no longer in admin section error log it is NOW appearing on the servers error_log.

I have removed all files for SMF 2.0 and uninstalled ALL pkgs. Reuploded the SMF files, reinstalled most of the pkgs, decided a few were not really needed and that has taken care of a lot of the errors this sillly forum has been giving out, so all files are brandspanking new. Ran updater files just in case --thanking Skhilled for his wonderful help so far

now the only other difference (actually before the removal of avatars from code) is this line:


old line: WHERE show_online = 1

my line:  WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '


any  idea why it is not behaving or giving this error


here is the code I am trying to use without the avatar, so I may have muffed it up too  ---also is there anyway to make the entries inline vs how they show now?

global $smcFunc, $scripturl, $modSettings, $context;

// Number of top posters displayed
$topPoster = 29;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],

);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="8">';

foreach ($users as $user)
{
echo '
<tr>

<td><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';



Skhilled

Ah! So it was a bad block after all. ;)

darkangel


IchBin

I don't see any error in the code you posted. Is that copied from your block? Line 31 in your code is blank line, so that leads me to think that your code that you posted isn't exactly as you have it in your block, or you pasted the wrong code here.

If you want the output inline you just need to edit the table code at the bottom. Don't be afraid to give things a try since you always have a backup copy of your code. :)

darkangel

This line?

<td><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';






Do I make it like this for inline:

<td><h5 style="margin: 4px;">'.$user['link'] . $user['posts'] .'</h5></td>
</tr>';


something like that?



this is copy/paste from block

global $smcFunc, $scripturl, $modSettings, $context;

// Number of top posters displayed
$topPoster = 29;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],

);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="8">';

foreach ($users as $user)
{
echo '
<tr>

<td><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';

IchBin

Quote from: darkangel on May 27, 2012, 12:19:38 AM
This line?

<td><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';






Do I make it like this for inline:

<td><h5 style="margin: 4px;">'.$user['link'] . $user['posts'] .'</h5></td>
</tr>';


something like that?

I don't know did you try it? :D

As for your code, still looks ok to me. Using the code on my test install I can't produce the error like you are. Something weird with your setup, who knows at this point.

darkangel

well was waiting to see if it was looking right but just did try it...does go inline but I need a space between name and post count....actually about20px maybe? and that I have no clue how to do in php

darn computer  posted...lol

anyway I would like to have the post count to the right of the name, almost to the right edge of block and no idea how to get that ac complished

IchBin

You don't have to do it in the PHP. You do it in the HTML parts. Separate anything else like you wouldn't in HTML. Put some padding in a tag around the parts you need, or put some &nbps in there.

darkangel

well not sure exactly how but will give it a go. ty

ZarPrime

Or you could just add in a second table cell into the row, sort of like this ...

{
echo '
<tr>

<td><h5 style="margin: 4px;">'.$user['link'].'</h5></td><td><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';
}


ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.