Wie kann das sein, dass es mal funktioniert mal nicht -> MySQL Fehler in PHP Script

dg87

Erfahrenes Mitglied
Guten Abend,

ich habe drei Websiten die unter Wordpress laufen. Da habe ich eine Schnittstelle, die mir die aktuellen Forenbeiträge auslesen.
Bei zwei meiner Seiten funktioniert es tadellos, aber bei einer funktionierts nicht, da bekomme ich diesen Fehler:

Code:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 ') ORDER BY thread.time DESC LIMIT 5' at line 4' in /var/www/web249/html/wp-content/plugins/wordpress-wbb_bridge/WcfWbbLatestPosts.class.php:181 Stack trace: #0 /var/www/web249/html/wp-content/plugins/wordpress-wbb_bridge/WcfWbbLatestPosts.class.php(181): PDOStatement->execute(Array) #1 /var/www/web249/html/wp-content/plugins/wordpress-wbb_bridge/widget.php(44): WcfWbbLatestPosts->displayThreads(Array, 5) #2 /var/www/web249/html/wp-includes/widgets.php(217): WBB_Posts_Widget->widget(Array, Array) #3 [internal function]: WP_Widget->display_callback(Array, Array) #4 /var/www/web249/html/wp-includes/widgets.php(1082): call_user_func_array(Array, Array) #5 /var/www/web249/html/wp-content/themes/ouya_leetpress_new/sidebar.php(4): dynamic_sidebar() #6 /var/www/web249/html in /var/www/web249/html/wp-content/plugins/wordpress-wbb_bridge/WcfWbbLatestPosts.class.php on line 181

Ich hab halt nicht viel Erfahrung darin. Anscheinend ist der Fehler hier drinnen:
Code:
$sql = "SELECT thread.lastPostID, thread.lastPoster, thread.lastPosterID, thread.topic, thread.lastPostTime, thread.threadID, board.title, thread.views, thread.replies, thread.userID, thread.username
				FROM wbb".WCF_N."_thread thread
				LEFT JOIN wbb".WCF_N."_board board ON (thread.boardID = board.boardID)
				WHERE thread.boardID IN (".implode(',',$boardIDs).")
				ORDER BY thread.time DESC
				LIMIT ".intval($limit);

Aber warum soll es unter gleichen Bedingungen bei den anderen zwei Seiten probemlos klappen und hier nicht :(
 
Der Tipp war gut, ein var_dump auf $boardIDs bringt mir array(0)

Der Query sieht so aus und liefert folgende Ergebnisse:
PHP:
"SELECT board.parentID, board.boardID, acl_group_everybody.optionValue as visibileToEverybody, acl_group_guest.optionValue as visibileToGuest
				FROM wbb".WCF_N."_board board
				LEFT JOIN wcf".WCF_N."_acl_option_to_group acl_group_everybody ON (acl_group_everybody.optionID = ".$aclOptionID." AND acl_group_everybody.objectID = board.boardID AND acl_group_everybody.groupID = 1)
				LEFT JOIN wcf".WCF_N."_acl_option_to_group acl_group_guest ON (acl_group_guest.optionID = ".$aclOptionID." AND acl_group_everybody.objectID = board.boardID  AND acl_group_guest.groupID = 2)";


PHP:
 parentID 	boardID 	visibileToEverybody 	visibileToGuest 	
NULL	11 	1 	1
NULL	11 	1 	1
NULL	11 	1 	1
NULL	11 	1 	0
NULL	18 	1 	1
NULL	18 	1 	1
NULL	18 	1 	1
NULL	18 	1 	0
NULL	28 	1 	1
NULL	28 	1 	1
NULL	28 	1 	1
NULL	28 	1 	0
NULL	35 	0 	1
NULL	35 	0 	1
NULL	35 	0 	1
NULL	35 	0 	0
11 	12 	NULL	NULL
11 	13 	NULL	NULL
11 	14 	NULL	NULL
11 	15 	NULL	NULL
11 	16 	NULL	NULL
11 	17 	NULL	NULL
11 	34 	NULL	NULL
11 	45 	NULL	NULL
11 	46 	NULL	NULL

Liest der vll dann die Variablen falsch ein?
Es muss ja nen Grund haben warum die null sind?
PHP:
$this->boardList = array();
		$this->boardChilds = array();
		
		// list every board child
		foreach ($result as $board) {
			$this->boardList[$board['boardID']] = $board;
			if ($board['parentID']) {
				if (empty($boardChilds[$board['parentID']])) $boardChilds[$board['parentID']] = array();
				$this->boardChilds[$board['parentID']][] = $board['boardID'];
			}
		}
		
		$finalBoardList = array();
		foreach ($this->boardList as $boardID => $board) {
			if ($this->isVisible($board)) $finalBoardList[] = $boardID;
		}
		return $finalBoardList;

ich peils nicht :(
 
Zuletzt bearbeitet:
Ok, du solltest mit dem Debuggen weiter machen. Als nächstes wäre die erste Schleife dran. Was ist vor der Schleife in $result drin? Was ist nach der Schleife in $this->boardList drin?
 
Jo bin ich grad dabei. Also Result hat auch die Ergebnisse wie oben dargestellt drinnen.
Kann es vll sein dass das hier mich zerlegt:
PHP:
$finalBoardList = array();
        foreach ($this->boardList as $boardID => $board) {
            if ($this->isVisible($board)) $finalBoardList[] = $boardID;
        }
weil ja visible auf null ist. oder ne muss ich gucken ob das überhaupt gemeint ist. aber in result steht noch alles sauber drinnen und die schleifen versteh ich nicht, die sind zu hart

Ne das ist es auch nicht - weil die function is visible prüft ob parentID null ist..

PHP:
	private function isVisible ($board) {
		$visible = $this->isVisibleHelper($board);

		if ($visible === null) {
			while ($visible === null) {
				if ($board['parentID'] === null) {
					$visible = true;
				}
				else {
					$board = $this->boardList[$board['parentID']];
					$visible = $this->isVisibleHelper($board);
				}
			}
		}
		return $visible;
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück