News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Can you help me make this module compatable with the new MYSQL?

Started by ss4vegito7, November 11, 2005, 10:51:01 PM

Previous topic - Next topic

ss4vegito7

So I patched up my SMF 1.1 because my host updated  8) But now this module doesn't work anymore. Its the Recent Topic Module for mambo, now I know this isn't the mambo section of the site but you guys here could probably help me more and the problem is with SMF not mambo.  ;)

The error I get is

Unknown column 't.ID_TOPIC' in 'on clause'
File: /home/mike/public_html/modules/mod_smf_recent_topics.php
Line: 69



I tried compairing it with the new recent.php that came with the patch but that didn't help.  :(

Below is the php

Thanks in advanced!


<?php
/**
* @version $Id: mod_smf_recent_topics.php,v 1.2 2005/04/07 2:35 kochp, rsuplido $
* @package Mambo
* @copyright (C) 2000 - 2005 Miro International Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
*/

/** ensure this file is being included by a parent file */
defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$board = ($params->get'board' )=="" $params->get'board' ));
$limit = ($params->get'limit' )=="" $params->get'limit' ));
$datetime = ($params->get'datetime' )=="" $params->get'datetime' ));
$numchar $params->get'numchar' );
$namedisplay = ($params->get('namedisplay')=="" $params->get'namedisplay' ));
$moduleclass_sfx $params->get'moduleclass_sfx' );


if (
$limit == '') {
	
die (
'Please go to Mambo-SMF Recent Topics module and click save to initialize parameters.');
}

global 
$context$txt$scripturl$settings$db_prefix$ID_MEMBER$user_info$modSettings;

global 
$smfItemid$mosConfig_sef;

$database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_smf'");
if (
$this->_result $database->query()) {
	
$row mysql_fetch_object($this->_result);
	
$smfItemid $row->id;
}

$myurl "index.php?option=com_smf&Itemid=" $smfItemid."&";

$scripturl $myurl;


$exclude_boards = array();
$output_method 'echo';


// Find all the posts.  Newer ones will have higher IDs.
$request db_query("
	
	
SELECT
	
	
	
mem.realName,
	
	
	
m.posterTime,
	
	
	
m2.subject,
	
	
	
t.ID_TOPIC,
	
	
	
t.ID_MEMBER_UPDATED,
	
	
	
t.ID_LAST_MSG,
	
	
	
m.ID_BOARD,
	
	
	
b.name AS bName,
	
	
	
t.numReplies,
	
	
	
m.posterName, " 
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS logTime' '
	
	
	
IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) >= GREATEST(m.posterTime, m.modifiedTime) AS isRead,
	
	
	
IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) AS logTime'
) . "
	
	
FROM smf_members AS mem, smf_topics AS t, smf_messages AS m, smf_messages AS m2, smf_boards AS b" 
. (!$user_info['is_guest'] ? "
	
	
	
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
	
	
	
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" '') . "
	
	
WHERE t.ID_BOARD = m.ID_BOARD
      
	
AND t.ID_BOARD = b.ID_BOARD" 
. (empty($exclude_boards) ? '' "
      
	
AND t.ID_BOARD NOT IN (" 
implode(', '$exclude_boards) . ")") . "
	
	
AND t.ID_LAST_MSG = m.ID_MSG
	
	
AND t.ID_FIRST_MSG = m2.ID_MSG
	
	
AND mem.memberName = m.posterName
	
	
ORDER BY m.posterTime DESC
	
	
LIMIT 
$limit"__FILE____LINE__);
$posts = array();

while (
$row mysql_fetch_assoc($request)) {
	
	
// Censor the subject.
	
	
censorText($row['subject']);

	
	
$posthref sefRelToAbs($scripturl 'topic=' $row['ID_TOPIC'] . '.msg' $row['ID_LAST_MSG'] . ';topicseen#msg' $row['ID_LAST_MSG']);
	
	
$posthref = (substr($posthref,strlen($posthref)-1)=="/" substr($posthref,0,strlen($posthref)-1) : $posthref );

	
	
// Build the array.
	
	
$posts[] = array(
	
	
	
'board' => array(
	
	
	
	
'id' => $row['ID_BOARD'],
	
	
	
	
'name' => $row['bName'],
	
	
	
	
'href' => $scripturl '?board=' $row['ID_BOARD'] . '.0',
	
	
	
	
'link' => '<a href="' sefRelToAbs($scripturl 'board=' $row['ID_BOARD'] . '.0').'">' $row['bName'] . '</a>'
	
	
	
),
	
	
	
'topic' => $row['ID_TOPIC'],
	
	
	
'poster' => array(
	
	
	
	
'name' => $row['posterName'],
	
	
	
	
'href' => empty($row['ID_MEMBER_UPDATED']) ? '' $scripturl 'action=profile;u=' $row['ID_MEMBER_UPDATED'],
	
	
	
	
'link' => empty($row['ID_MEMBER_UPDATED']) ? ($namedisplay == $row['realName'] : $row['posterName']) : '<a href="' sefRelToAbs($scripturl 'action=profile;u=' $row['ID_MEMBER_UPDATED']) . '">' . ($namedisplay == $row['realName'] : $row['posterName']) . '</a>'
	
	
	
),
	
	
	
'subject' => $row['subject'],
	
	
	
'short_subject' => strlen(un_htmlspecialchars($row['subject'])) > 25 htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 022) . '...') : $row['subject'],
	
	
	
'time' => timeformat($row['posterTime']),
	
	
	
'timestamp' => $row['posterTime'],
	
	
	
'href' => $posthref,
	
	
	
'link' => '<a href="' $scripturl 'topic=' $row['ID_TOPIC'] . '.msg' $row['ID_LAST_MSG'] . '#msg' $row['ID_LAST_MSG'] . '">' $row['subject'] . '</a>',
	
	
	
'new' => !empty($row['isRead']),
	
	
	
'newtime' => $row['logTime'],
	
	
	
'replies' => $row['numReplies']
	
	
);
}

mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
	
return 
$posts;

echo 
'
	
<ul class="latesnews'
,$moduleclass_sfx,'">
	
'
;
foreach (
$posts as $post) {
	
	
$newlink sefRelToAbs($scripturl 'topic=' $post['topic'] . '.from' $post['newtime']);
	
	
$newlink = (substr($newlink,strlen($newlink)-1) == "/" substr($newlink,0,strlen($newlink)-1) : $newlink);
	
    echo 
'<li class="latestnews',$moduleclass_sfx,'">';
	
    echo 
'<a class="latestnews',$moduleclass_sfx,'" href="'$post['href'], '">';
	
    if (
$board == && $board != '') {
	
	
	
echo 
'<i>',$post['board']['name'], '</i> : ';
	
	
}
	
	
echo (
$numchar != '' substr($post['subject'],0,$numchar).(strlen($post['subject']) > $numchar '...' '') : $post['subject']) , '</a> (',
	
	
	
$post['replies'], ') '$txt[525], ' ', ($mosConfig_sef == '1' str_replace(";","/",$post['poster']['link']) : $post['poster']['link']) , '
	
	
	
'
$post['new'] ? '' '<a href="' $newlink ';topicseen#new"><img src="' $settings['images_url'] . '/' $context['user']['language'] . '/new.gif" alt="' $txt[302] . '" border="0" /></a>';
	
	
if (
$datetime == && $datetime != '') {
	
	
	
echo 
' - ',$post['time'];
	
	
}
	
	
echo 
"</li>\n";
}
echo 
'</ul>';


?>







ss4vegito7


Bonk

You must tell the mambo people that if they are going to integrate with other scripts then they must keep up to date and provide compatibilty for multiple versions of the script they are trying to integrate with. The problem you are having is not SMF, it is a mambo script.

What is wrong with a simple:


<?php ssi_recentTopics(); ?>


In a page of your own creation?

See it work just fine here:
http://www.simplemachines.org/community/ssi_examples.php

ss4vegito7

This mambo mod was created by a user and is not the official SMF recent topics mod. Just like the mods made for SMF many don't work anymore. The official mod works but its too simple and doesn't offer then functionality and customization that this one does.  :(

ss4vegito7

Anyway, if this was a mambo error why does it bring SMF up in a frame and show it giving an error?

JayBachatero

Try this


<?php
/**
* @version $Id: mod_smf_recent_topics.php,v 1.2 2005/04/07 2:35 kochp, rsuplido $
* @package Mambo
* @copyright (C) 2000 - 2005 Miro International Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
*/

/** ensure this file is being included by a parent file */
defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$board = ($params->get'board' )=="" $params->get'board' ));
$limit = ($params->get'limit' )=="" $params->get'limit' ));
$datetime = ($params->get'datetime' )=="" $params->get'datetime' ));
$numchar $params->get'numchar' );
$namedisplay = ($params->get('namedisplay')=="" $params->get'namedisplay' ));
$moduleclass_sfx $params->get'moduleclass_sfx' );


if (
$limit == '') {
	
die (
'Please go to Mambo-SMF Recent Topics module and click save to initialize parameters.');
}

global 
$context$txt$scripturl$settings$db_prefix$ID_MEMBER$user_info$modSettings;

global 
$smfItemid$mosConfig_sef;

$database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_smf'");
if (
$this->_result $database->query()) {
	
$row mysql_fetch_object($this->_result);
	
$smfItemid $row->id;
}

$myurl "index.php?option=com_smf&Itemid=" $smfItemid."&";

$scripturl $myurl;


$exclude_boards = array();
$output_method 'echo';


// Find all the posts.  Newer ones will have higher IDs.
$request db_query("
	
	
SELECT
	
	
	
mem.realName,
	
	
	
m.posterTime,
	
	
	
m2.subject,
	
	
	
t.ID_TOPIC,
	
	
	
t.ID_MEMBER_UPDATED,
	
	
	
t.ID_LAST_MSG,
	
	
	
m.ID_BOARD,
	
	
	
b.name AS bName,
	
	
	
t.numReplies,
	
	
	
m.posterName, " 
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS logTime' '
	
	
	
IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) >= GREATEST(m.posterTime, m.modifiedTime) AS isRead,
	
	
	
IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) AS logTime'
) . "
	
	
{FROM smf_members AS mem, smf_topics AS t, smf_messages AS m, smf_messages AS m2, smf_boards AS b}" 
. (!$user_info['is_guest'] ? "
	
	
	
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
	
	
	
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" '') . "
	
	
WHERE t.ID_BOARD = m.ID_BOARD
      
	
AND t.ID_BOARD = b.ID_BOARD" 
. (empty($exclude_boards) ? '' "
      
	
AND t.ID_BOARD NOT IN (" 
implode(', '$exclude_boards) . ")") . "
	
	
AND t.ID_LAST_MSG = m.ID_MSG
	
	
AND t.ID_FIRST_MSG = m2.ID_MSG
	
	
AND mem.memberName = m.posterName
	
	
ORDER BY m.posterTime DESC
	
	
LIMIT 
$limit"__FILE____LINE__);
$posts = array();

while (
$row mysql_fetch_assoc($request)) {
	
	
// Censor the subject.
	
	
censorText($row['subject']);

	
	
$posthref sefRelToAbs($scripturl 'topic=' $row['ID_TOPIC'] . '.msg' $row['ID_LAST_MSG'] . ';topicseen#msg' $row['ID_LAST_MSG']);
	
	
$posthref = (substr($posthref,strlen($posthref)-1)=="/" substr($posthref,0,strlen($posthref)-1) : $posthref );

	
	
// Build the array.
	
	
$posts[] = array(
	
	
	
'board' => array(
	
	
	
	
'id' => $row['ID_BOARD'],
	
	
	
	
'name' => $row['bName'],
	
	
	
	
'href' => $scripturl '?board=' $row['ID_BOARD'] . '.0',
	
	
	
	
'link' => '<a href="' sefRelToAbs($scripturl 'board=' $row['ID_BOARD'] . '.0').'">' $row['bName'] . '</a>'
	
	
	
),
	
	
	
'topic' => $row['ID_TOPIC'],
	
	
	
'poster' => array(
	
	
	
	
'name' => $row['posterName'],
	
	
	
	
'href' => empty($row['ID_MEMBER_UPDATED']) ? '' $scripturl 'action=profile;u=' $row['ID_MEMBER_UPDATED'],
	
	
	
	
'link' => empty($row['ID_MEMBER_UPDATED']) ? ($namedisplay == $row['realName'] : $row['posterName']) : '<a href="' sefRelToAbs($scripturl 'action=profile;u=' $row['ID_MEMBER_UPDATED']) . '">' . ($namedisplay == $row['realName'] : $row['posterName']) . '</a>'
	
	
	
),
	
	
	
'subject' => $row['subject'],
	
	
	
'short_subject' => strlen(un_htmlspecialchars($row['subject'])) > 25 htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 022) . '...') : $row['subject'],
	
	
	
'time' => timeformat($row['posterTime']),
	
	
	
'timestamp' => $row['posterTime'],
	
	
	
'href' => $posthref,
	
	
	
'link' => '<a href="' $scripturl 'topic=' $row['ID_TOPIC'] . '.msg' $row['ID_LAST_MSG'] . '#msg' $row['ID_LAST_MSG'] . '">' $row['subject'] . '</a>',
	
	
	
'new' => !empty($row['isRead']),
	
	
	
'newtime' => $row['logTime'],
	
	
	
'replies' => $row['numReplies']
	
	
);
}

mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
	
return 
$posts;

echo 
'
	
<ul class="latesnews'
,$moduleclass_sfx,'">
	
'
;
foreach (
$posts as $post) {
	
	
$newlink sefRelToAbs($scripturl 'topic=' $post['topic'] . '.from' $post['newtime']);
	
	
$newlink = (substr($newlink,strlen($newlink)-1) == "/" substr($newlink,0,strlen($newlink)-1) : $newlink);
	
    echo 
'<li class="latestnews',$moduleclass_sfx,'">';
	
    echo 
'<a class="latestnews',$moduleclass_sfx,'" href="'$post['href'], '">';
	
    if (
$board == && $board != '') {
	
	
	
echo 
'<i>',$post['board']['name'], '</i> : ';
	
	
}
	
	
echo (
$numchar != '' substr($post['subject'],0,$numchar).(strlen($post['subject']) > $numchar '...' '') : $post['subject']) , '</a> (',
	
	
	
$post['replies'], ') '$txt[525], ' ', ($mosConfig_sef == '1' str_replace(";","/",$post['poster']['link']) : $post['poster']['link']) , '
	
	
	
'
$post['new'] ? '' '<a href="' $newlink ';topicseen#new"><img src="' $settings['images_url'] . '/' $context['user']['language'] . '/new.gif" alt="' $txt[302] . '" border="0" /></a>';
	
	
if (
$datetime == && $datetime != '') {
	
	
	
echo 
' - ',$post['time'];
	
	
}
	
	
echo 
"</li>\n";
}
echo 
'</ul>';


?>

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

ss4vegito7

Thanks for the try Jay!  :) But i still get an error with the code u posted.  :(

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 '{FROM smf_members AS mem, smf_topics AS t, smf_messages AS m, smf_messages AS m2' at line 103
File: /home/mike/public_html/modules/mod_smf_recent_topics.php
Line: 224

could u maybe give me an idea of what needs to be changed to be compatable?

ss4vegito7

It always seems to have a problem with this line of code.

LIMIT $limit", __FILE__, __LINE__);

I wonder why  ???

JayBachatero

I guess you can try asking for help over at the mambo/joomla boards since this is related to it.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

CapriSkye

or you could tell mysql to use traditional mode.
just change the sql mode in my.ini to this
sql-mode=""

ss4vegito7


CapriSkye

if you're using windows, and depending on how you installed mysql, my.ini is either in mysql folder or c:/windows.

JayBachatero

Are you on a dedicated server?  The only way that you can edit this if you are on a dedicated box.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

ss4vegito7

oh, no i share the server with alot of other sites.

Damn i wish I could just go back to the old version.  :(

ss4vegito7

Finally, I fixed it!

replace this (on or around line 59)


FROM smf_members AS mem, smf_topics AS t, smf_messages AS m, smf_messages AS m2, smf_boards AS b" . (!$user_info['is_guest'] ? "



With this


FROM ({$db_prefix}members AS mem, {$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}messages AS m2, {$db_prefix}boards AS b)" . (!$user_info['is_guest'] ? "



Thanks everyone for ur help trying to fix it!

Advertisement: