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: 458
  • Total: 458

error related with db_query after updating to SMF 2.0

Started by obarriel, August 15, 2011, 02:24:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

obarriel

It is not putting vertical space between lines. It only puts space between the bullet and the first letter of the line.

ZarPrime

I think rather than a line break at the end of the code, a horizontal line (hr) would look better.  Have you tried that?

ZarPrime

IchBin

Put the bullet inside the span.

Change this:
echo $bullet .'
   <span class="normaltext" style="padding: 8px">' . $my['board']['link'] . ' :

To this:
echo '
   <span class="normaltext" style="padding: 8px">'. $bullet . $my['board']['link'] . ' :

Change the padding: 8px; to line-height: 1.5em; and see if that helps. If it does not, please leave your code in place so I can inspect it on your site to see what needs to be changed.

obarriel

Putting the bullet inside the span gives me an error.

With an horizontal line looks quite good and the vertical spacing is more or less what I wanted

This is the code I use now:

global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $smcFunc;

$num_recent = 16;
$include_boards = array(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,39,41,42,44,45,47,49);

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('', '
SELECT
m.poster_time, ms.subject, m.id_topic, t.num_views, t.num_replies, m.id_member, m.id_msg, b.id_board, b.name AS bName,
IFNULL(mem.real_name, m.poster_name) AS posterName, ' . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS isRead,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, m.icon
FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = '. $context['user']['id'].')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = '.$context['user']['id'].')' : '') . '
WHERE t.id_last_msg >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
AND t.id_last_msg = m.id_msg
AND b.id_board = t.id_board' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
' . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? '
AND b.id_board != '. $modSettings['recycle_board'] : '') . '
AND {query_see_board}
AND ms.id_msg = t.id_first_msg
ORDER BY t.id_last_msg DESC
LIMIT {int:num}',
array('include_boards' => $include_boards, 'num' => $num_recent)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$result[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => array(
'id' => $row['id_topic'],
'views' => $row['num_views'],
'replies' => $row['num_replies'],
),
'poster' => array(
'id' => $row['id_member'],
'name' => $row['posterName'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}

$smcFunc['db_free_result']($request);
// Print out the results
  echo '<span class="smallertext">','<br>';
foreach($result as $my)
{
echo $bullet .'
<span class="normaltext" style="padding: 8px">' . $my['board']['link'] . ' : <span class="normaltext" style="font-weight: bold;">'. $my['link']  .'</span>
por '. $my['poster']['link'] .'('.$my['topic']['replies'].')'; 
// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
<a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt['new'], '" border="0" />
</a>
</span>';
                echo '<hr />';
}

IchBin

How come you added this part?
echo '<span class="smallertext">','<br>';

That actually is incorrect as every tag must have an ending tag. You start the < span > tag but do not end it. Do you need that code there for some reason?

Try this code:
global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $smcFunc;

$num_recent = 16;
$include_boards = array(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,39,41,42,44,45,47,49);

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('', '
SELECT
m.poster_time, ms.subject, m.id_topic, t.num_views, t.num_replies, m.id_member, m.id_msg, b.id_board, b.name AS bName,
IFNULL(mem.real_name, m.poster_name) AS posterName, ' . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS isRead,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, m.icon
FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = '. $context['user']['id'].')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = '.$context['user']['id'].')' : '') . '
WHERE t.id_last_msg >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
AND t.id_last_msg = m.id_msg
AND b.id_board = t.id_board' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
' . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? '
AND b.id_board != '. $modSettings['recycle_board'] : '') . '
AND {query_see_board}
AND ms.id_msg = t.id_first_msg
ORDER BY t.id_last_msg DESC
LIMIT {int:num}',
array('include_boards' => $include_boards, 'num' => $num_recent)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$result[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => array(
'id' => $row['id_topic'],
'views' => $row['num_views'],
'replies' => $row['num_replies'],
),
'poster' => array(
'id' => $row['id_member'],
'name' => $row['posterName'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}

$smcFunc['db_free_result']($request);
// Print out the results
foreach($result as $my)
{
echo '<span class="normaltext" style="padding: 8px">' . $bullet . $my['board']['link'] . ' : <span class="normaltext" style="font-weight: bold;">'. $my['link']  .'</span>
por '. $my['poster']['link'] .'('.$my['topic']['replies'].')'; 
// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
<a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt['new'], '" border="0" />
</a>
</span>';
                echo '<hr />';
}

obarriel

Sorry for not reporting before. This code works just fine. There was an small error with ID_BOARD written in capital letters, once corrected the code is:


global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $smcFunc;

$num_recent = 16;
$include_boards = array(1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,39,41,42,44,45,47,49);

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('', '
SELECT
m.poster_time, ms.subject, m.id_topic, t.num_views, t.num_replies, m.id_member, m.id_msg, b.id_board, b.name AS bName,
IFNULL(mem.real_name, m.poster_name) AS posterName, ' . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS isRead,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, m.icon
FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = '. $context['user']['id'].')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = '.$context['user']['id'].')' : '') . '
WHERE t.id_last_msg >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
AND t.id_last_msg = m.id_msg
AND b.id_board = t.id_board' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
' . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? '
AND b.id_board != '. $modSettings['recycle_board'] : '') . '
AND {query_see_board}
AND ms.id_msg = t.id_first_msg
ORDER BY t.id_last_msg DESC
LIMIT {int:num}',
array('include_boards' => $include_boards, 'num' => $num_recent)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$result[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => array(
'id' => $row['id_topic'],
'views' => $row['num_views'],
'replies' => $row['num_replies'],
),
'poster' => array(
'id' => $row['id_member'],
'name' => $row['posterName'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}

$smcFunc['db_free_result']($request);
// Print out the results
foreach($result as $my)
{
echo '<span class="normaltext" style="padding: 8px">' . $bullet  . $my['board']['link'] . ' : <span class="normaltext" style="font-weight: bold;">'. $my['link']  .'</span>
por '. $my['poster']['link'] .'('.$my['topic']['replies'].')'; 
// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
<a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt['new'], '" border="0" />
</a>
</span>';
                echo '<hr />';
}


Anybody who wants to use it you can check the output at www.reproductormp3.net

This website is proudly hosted on Crocweb Cloud Website Hosting.