Probleem met forum waarschijnlijk database

Installatie lukt niet? Plotseling een foutmelding. Of weet je niet hoe iets werkt. Problemen met phpBB2 kun je in dit archief opzoeken.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
Gebruikersavatar
The Crow
Berichten: 224
Lid geworden op: 12 mei 2003, 20:47

Probleem met forum waarschijnlijk database

Bericht door The Crow » 07 nov 2004, 19:50

Ik krijg deze tekst als ik naar een topic wilt.

Code: Selecteer alles

Could not obtain topic information

DEBUG MODE

SQL Error : 1064 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 '' at line 11

SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time FROM phpbb_topics t, phpbb_users u, phpbb_posts p, phpbb_posts p2, phpbb_users u2 WHERE t.forum_id = 1 AND t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id AND t.topic_type <> 2 ORDER BY t.topic_type DESC, t.topic_status ASC, t.topic_last_post_id DESC LIMIT 0,
Line : 327
File : /home/spamhotel.nl/www/viewforum.php
Wat kan ik hieraan doen??

cartoontje
Berichten: 1518
Lid geworden op: 29 jun 2003, 10:57
Locatie: Home Sweet Home
Contacteer:

Bericht door cartoontje » 07 nov 2004, 20:37

Post eens viewforum.php lijn 220 t/m 240!

Gebruikersavatar
The Crow
Berichten: 224
Lid geworden op: 12 mei 2003, 20:47

Bericht door The Crow » 07 nov 2004, 20:48

Alstublieft

Code: Selecteer alles

{
	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}

while( $row = $db->sql_fetchrow($result) )
{
	$moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
}
	
$l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
$forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
unset($moderators);

//
// Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent
// then get it's value, find the number of topics with dates newer than it (to properly
// handle pagination) and alter the main query
//
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
$previous_days_text = array($lang['All_Topics'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);

if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) )
{
	$topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? intval($HTTP_POST_VARS['topicdays']) : intval($HTTP_GET_VARS['topicdays']);
	$min_topic_time = time() - ($topic_days * 86400);

	$sql = "SELECT COUNT(t.topic_id) AS forum_topics 
		FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
		WHERE t.forum_id = $forum_id 
			AND p.post_id = t.topic_last_post_id
			AND p.post_time >= $min_topic_time"; 

	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);

	$topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;
	$limit_topics_time = "AND p.post_time >= $min_topic_time";

	if ( !empty($HTTP_POST_VARS['topicdays']) )
	{
		$start = 0;
	}
}
else
{
	$topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;

	$limit_topics_time = '';
	$topic_days = 0;
}

$select_topic_days = '<select name="topicdays">';
for($i = 0; $i < count($previous_days); $i++)
{
	$selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
	$select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
}
$select_topic_days .= '</select>';


//
// All announcement data, this keeps announcements
// on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id 
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_last_post_id
		AND p.poster_id = u2.user_id
		AND t.topic_type = " . POST_ANNOUNCE . " 
	ORDER BY t.topic_last_post_id DESC ";
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

cartoontje
Berichten: 1518
Lid geworden op: 29 jun 2003, 10:57
Locatie: Home Sweet Home
Contacteer:

Bericht door cartoontje » 07 nov 2004, 20:57

Sorry, typfoutje! :oops:

320 t/m 340! :)

En kun je even aangeven welke lijn 327 is.

Gebruikersavatar
The Crow
Berichten: 224
Lid geworden op: 12 mei 2003, 20:47

Bericht door The Crow » 07 nov 2004, 21:12

AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time
ORDER BY t.topic_type DESC, t.topic_status ASC, t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$total_topics = 0;
while( $row = $db->sql_fetchrow($result) )
{
$topic_rowset[] = $row;
$total_topics++;
}

$db->sql_freeresult($result);

//
// Total topics ...
//
$total_topics += $total_announcements;

//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

//
// Post URL generation for templating vars
//
$template->assign_vars(array(
'L_DISPLAY_TOPICS' => $lang['Display_topics'],

'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"),

'S_SELECT_TOPIC_DAYS' => $select_topic_days,
'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&start=$start"))
);

//
// User authorisation levels output
//
$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';

if ( $is_auth['auth_mod'] )
{
$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&start=" . $start . "&sid=" . $userdata['session_id'] . '">', '</a>');
}

Gebruikersavatar
mosymuis
Berichten: 6940
Lid geworden op: 05 feb 2003, 14:00
Locatie: Amsterdam
Contacteer:

Bericht door mosymuis » 07 nov 2004, 23:01

cartoontje, bij SQL errors kan je in de query al zien wat er fout gaat, de regel die PHP zal aanwijzen is altijd degene waar de query word uitgevoerd. Daar heb je dan ook bar weinig aan.

In dit geval eindigt de query te vroeg, in de LIMIT opdracht. $board_config['topics_per_page'] bestaat dus niet, op de plek waar hij word aangeroepen. Dit is een standaard config waarde van phpBB, dus ik benieuwd hoe je die bent kwijt geraakt. Zo krijg je hem terug:

Code: Selecteer alles

INSERT INTO phpbb_config VALUES('topics_per_page', 15);

Gebruikersavatar
The Crow
Berichten: 224
Lid geworden op: 12 mei 2003, 20:47

Bericht door The Crow » 08 nov 2004, 00:35

Als ik dat doe krijg ik dit bericht terug:

Code: Selecteer alles

 MySQL said: Documentation
#1062 - Duplicate entry 'topics_per_page' for key 1
Dus weet niet wat ik fout doe
Wijziging: is opgelost, die value zat er nog in, heb hem verwijderd en die query uitgevoerd en het werkt weer perfect
Thnx mosymuis :thumb:
Laatst gewijzigd door The Crow op 08 nov 2004, 00:45, 1 keer totaal gewijzigd.

Gebruikersavatar
mosymuis
Berichten: 6940
Lid geworden op: 05 feb 2003, 14:00
Locatie: Amsterdam
Contacteer:

Bericht door mosymuis » 08 nov 2004, 00:44

De rij bestaat dus wel, waarom hij die dan niet laat zien in je query kan ik zo niet zeggen.

Wat zoiezo zal werken, is dit:

Zoek

Code: Selecteer alles

 LIMIT $start, ".$board_config['topics_per_page'];
Vervang met

Code: Selecteer alles

 LIMIT $start, 15";
maar een erg nette oplossing is dit niet, omdat je de waarde dan niet meer kan wijzigen in je admincp.

Gebruikersavatar
The Crow
Berichten: 224
Lid geworden op: 12 mei 2003, 20:47

Bericht door The Crow » 08 nov 2004, 00:45

Het is opgelost zie de post van mij voor die van jou hoe ik het gedaan hebt ;)

Gebruikersavatar
The Crow
Berichten: 224
Lid geworden op: 12 mei 2003, 20:47

Bericht door The Crow » 08 nov 2004, 16:45

Ik ben erachter, ik krijg die melding als ik iets in de configuratie verander, maakt niet uit wat maar dan geeft ie die fout aan, klopt niet helemaal geloof ik

Gesloten