Seite 1 von 1

[gelöst] SQL Error : 1054 Unknown column

Verfasst: 01.05.2011 15:56
von Morpheus-LB
Hallo zusammen.

Nach aufspielen eines Backups, bekomme ich nun immer folgenden Fehler-Meldung, wenn ich auf "Letzte Themen" gehe:

Code: Alles auswählen

Allgemeiner Fehler
 
could not obtain main information.

DEBUG MODE

SQL Error : 1054 Unknown column 't.topic_first_post_id' in 'on clause'

SELECT t.*, p.poster_id, p.post_username AS last_poster_name, p.post_id, p.post_time, f.forum_name, f.forum_id, u.username AS last_poster, u.user_id AS last_poster_id, u2.username AS first_poster, u2.user_id AS first_poster_id, p2.post_username AS first_poster_name FROM phpbb_topics t, phpbb_posts p LEFT OUTER JOIN phpbb_posts p2 ON p2.post_id = t.topic_first_post_id LEFT OUTER JOIN phpbb_forums f ON p.forum_id = f.forum_id LEFT OUTER JOIN phpbb_users u ON p.poster_id = u.user_id LEFT OUTER JOIN phpbb_users u2 ON u2.user_id = t.topic_poster WHERE t.forum_id NOT IN ('start') AND p.post_id = t.topic_last_post_id AND UNIX_TIMESTAMP(NOW()) - p.post_time < 86400 ORDER BY t.topic_last_post_id DESC LIMIT 0, 25

Line : 127
File : recent.php

kann mir hier jemand weiter helfen ??

Besten Dank vorab

Re: SQL Error : 1054 Unknown column 't.topic_first_post_id'

Verfasst: 01.05.2011 16:18
von Mahony
Hallo
Hier die Lösung für dein Problem.

Code: Alles auswählen

#
#-----[ OPEN ]------------------------------------------------ 
#

recent.php

#
#-----[ FIND ]------------------------------------------------ 
#

	        FROM ". TOPICS_TABLE ." t, ". POSTS_TABLE ." p

# 
#-----[ REPLACE WITH ]---------------------------------------- 
#

	        FROM (". TOPICS_TABLE ." t, ". POSTS_TABLE ." p)
Grüße: Mahony

Re: SQL Error : 1054 Unknown column 't.topic_first_post_id'

Verfasst: 01.05.2011 16:55
von Morpheus-LB
Hallo Mahony.

Sorry...das hat aber leider nichts gebracht...
Der Fehler besteht immer noch...hatte ich erwähnt, daß es ein Mod ist ?
Wenn nicht...sorry :oops:

Re: SQL Error : 1054 Unknown column 't.topic_first_post_id'

Verfasst: 01.05.2011 17:28
von Mahony
Hallo
Morpheus-LB hat geschrieben:Sorry...das hat aber leider nichts gebracht...
Der Fehler besteht immer noch...
Doch, das ist genau die Lösung für dein Problem. Am besten, du zeigst uns mal deine recent.php im Pastebin
Morpheus-LB hat geschrieben:...hatte ich erwähnt, daß es ein Mod ist ?
Nein, aber das ist für die Lösung des Problems, in diesem Fall, auch nicht relevant.

Erklärung:
Auf deinem Server wurde eine neue MYSQL-Version (Version 5) installiert.

Hier mal eine kleine Hilfe dazu
However, the precedence of the comma operator is less than of INNER JOIN, CROSS JOIN, LEFT JOIN, and so on. If you mix comma joins with the other join types when there is a join condition, an error of the form Unknown column 'col_name' in 'on clause' may occur. Information about dealing with this problem is given later in this section.
und das hier
#

Previously, the comma operator (,) and JOIN both had the same precedence, so the join expression t1, t2 JOIN t3 was interpreted as ((t1, t2) JOIN t3). Now JOIN has higher precedence, so the expression is interpreted as (t1, (t2 JOIN t3)). This change affects statements that use an ON clause, because that clause can refer only to columns in the operands of the join, and the change in precedence changes interpretation of what those operands are.

Example:

CREATE TABLE t1 (i1 INT, j1 INT);
CREATE TABLE t2 (i2 INT, j2 INT);
CREATE TABLE t3 (i3 INT, j3 INT);
INSERT INTO t1 VALUES(1,1);
INSERT INTO t2 VALUES(1,1);
INSERT INTO t3 VALUES(1,1);
SELECT * FROM t1, t2 JOIN t3 ON (t1.i1 = t3.i3);

Previously, the SELECT was legal due to the implicit grouping of t1,t2 as (t1,t2). Now the JOIN takes precedence, so the operands for the ON clause are t2 and t3. Because t1.i1 is not a column in either of the operands, the result is an Unknown column 't1.i1' in 'on clause' error. To allow the join to be processed, group the first two tables explicitly with parentheses so that the operands for the ON clause are (t1,t2) and t3:

SELECT * FROM (t1, t2) JOIN t3 ON (t1.i1 = t3.i3);

Alternatively, avoid the use of the comma operator and use JOIN instead:

SELECT * FROM t1 JOIN t2 JOIN t3 ON (t1.i1 = t3.i3);

This change also applies to statements that mix the comma operator with INNER JOIN, CROSS JOIN, LEFT JOIN, and RIGHT JOIN, all of which now have higher precedence than the comma operator.
Quelle




Grüße: Mahony

Re: SQL Error : 1054 Unknown column 't.topic_first_post_id'

Verfasst: 01.05.2011 17:48
von Morpheus-LB
habe die recent.php unter gleichen Namen dort hochgeladen

Re: SQL Error : 1054 Unknown column 't.topic_first_post_id'

Verfasst: 01.05.2011 18:38
von Mahony
Hallo
Suche

Code: Alles auswählen

$where_forums = ( $special_forums == '0' ) ? 't.forum_id NOT IN ('. $except_forums .')' : 't.forum_id NOT IN ('. $except_forums .') AND t.forum_id IN ('. $forum_ids .')';
$sql_start = "SELECT t.*, p.poster_id, p.post_username AS last_poster_name, p.post_id, p.post_time, f.forum_name, f.forum_id, u.username AS last_poster, u.user_id AS last_poster_id, u2.username AS first_poster, u2.user_id AS first_poster_id, p2.post_username AS first_poster_name
            FROM ". TOPICS_TABLE ." t, ". POSTS_TABLE ." p
        LEFT OUTER JOIN ". POSTS_TABLE ." p2 ON p2.post_id = t.topic_first_post_id
        LEFT OUTER JOIN ". FORUMS_TABLE ." f ON p.forum_id = f.forum_id
        LEFT OUTER JOIN ". USERS_TABLE ." u ON p.poster_id = u.user_id
        LEFT OUTER JOIN ". USERS_TABLE ." u2 ON u2.user_id = t.topic_poster
            WHERE $where_forums AND p.post_id = t.topic_last_post_id AND ";
$sql_end = "  ORDER BY t.topic_last_post_id DESC LIMIT $start, $topic_limit
Ersetze mit

Code: Alles auswählen

$where_forums = ( $special_forums == '0' ) ? 't.forum_id NOT IN ('. $except_forums .')' : 't.forum_id NOT IN ('. $except_forums .') AND t.forum_id IN ('. $forum_ids .')';
$sql_start = "SELECT t.*, p.poster_id, p.post_username AS last_poster_name, p.post_id, p.post_time, f.forum_name, f.forum_id, u.username AS last_poster, u.user_id AS last_poster_id, u2.username AS first_poster, u2.user_id AS first_poster_id, p2.post_username AS first_poster_name
            FROM (". TOPICS_TABLE ." t, ". POSTS_TABLE ." p)
        LEFT OUTER JOIN ". POSTS_TABLE ." p2 ON p2.post_id = t.topic_first_post_id
        LEFT OUTER JOIN ". FORUMS_TABLE ." f ON p.forum_id = f.forum_id
        LEFT OUTER JOIN ". USERS_TABLE ." u ON p.poster_id = u.user_id
        LEFT OUTER JOIN ". USERS_TABLE ." u2 ON u2.user_id = t.topic_poster
            WHERE $where_forums AND p.post_id = t.topic_last_post_id AND ";
$sql_end = "  ORDER BY t.topic_last_post_id DESC LIMIT $start, $topic_limit"; 
Grüße: Mahony

Re: SQL Error : 1054 Unknown column 't.topic_first_post_id'

Verfasst: 01.05.2011 19:24
von Morpheus-LB
Suppi...danke Mahony... :grin:

Das Problem ist gelöst...nochmals Danke.