參考連結:http://phpbb-tw.net/phpbb/viewtopic.php?t=20650
使用版本:phpBB 2.0.21
網站位置:http://www.mascoteventclub.ez2.us/ForTest/
狀況描述:
在裝了這個外掛後....
在點選文章標題要進入時,就會出現這樣的訊息.....
而我確定我這個資料庫的欄位已經有加入了.....phpBB : Critical Error
Error create user view topic information
DEBUG MODE
SQL Error : 1146 Table 'mascoteventclub.topic_view_table' doesn't exist
INSERT IGNORE INTO TOPIC_VIEW_TABLE (topic_id, user_id, view_time,view_count) VALUES (400, "3", "1151001377","1")
Line : 216
File : viewtopic.php
而看這個錯誤訊息的敘述....
感覺像是viewtopic.php在執行時,沒有認識到資料庫裡有這個欄位...
所以無法將點選的資料寫入.....
而在當初安裝時其中有段程式碼是這樣
而我因為之前裝過了完整備份資料庫的外掛....#
#-----[ OPEN ]------------------------------------------------
#
admin/admin_db_utilities.php
#
#-----[ FIND ]------------------------------------------------
#
$tables = array(
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Start add - Who viewed a topic MOD
$tables[] = 'topic_view';
// End add - Who viewed a topic MOD
所以在$tables = array(這段程式碼的地方已經變更為
而這段的前面和後面都和原始的相同$phpbb_only = (!empty($HTTP_POST_VARS['phpbb_only'])) ? $HTTP_POST_VARS['phpbb_only'] : ( (!empty($HTTP_GET_VARS['phpbb_only'])) ? $HTTP_GET_VARS['phpbb_only'] : 0 );
switch ( SQL_LAYER )
{
case 'mysql':
case 'mysql4':
$sql = 'SHOW TABLES';
$field = "Tables_in_{$dbname}";
break;
case 'postgresql':
$sql = "SELECT relname
FROM pg_class
WHERE relkind = 'r'
AND relname NOT LIKE 'pg\_%'";
$field = "relname";
break;
}
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$current_table = $row[$field];
$current_prefix = substr($current_table, 0, strlen($table_prefix));
if ($phpbb_only && $current_prefix != $table_prefix)
{
continue;
}
else
{
$tables[] = $current_table;
}
}
所以我是在這段後面直接加上了他要加入的
// Start add - Who viewed a topic MOD
$tables[] = 'topic_view';
// End add - Who viewed a topic MOD
可是結果仍舊是失敗的.....
不知道該怎樣修改讓他可以成功的認識topic_view這個Table呢?
還是說這兩個外掛就是注定相衝了?
另外,附上錯誤的viewtopic.php 216行附近的程式碼....
謝謝諸位了......
紅色字為剛好的第216行
//
// End auth check
//
// Start add - Who viewed a topic MOD
$user_id=$userdata['user_id'];
$sql='UPDATE '.TOPIC_VIEW_TABLE.' SET topic_id="'.$topic_id.'", view_time="'.time().'", view_count=view_count+1 WHERE topic_id='.$topic_id.' AND user_id='.$user_id;
if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
$sql = 'INSERT IGNORE INTO '.TOPIC_VIEW_TABLE.' (topic_id, user_id, view_time,view_count)
VALUES ('.$topic_id.', "'.$user_id.'", "'.time().'","1")';
if ( !($db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Error create user view topic information ', '', __LINE__, __FILE__, $sql);
}
}
// End add - Who viewed a topic MOD


