Jump to content
php.lv forumi

SQL error


daviskrex

Recommended Posts

Sveiki!

Īsti nevaru saprast, ko esmu nostrādājis greizi

			SELECT `comments`.*, `forum_posts`.* 
		FROM `comments`
		FULL JOIN `forum_posts`
		ON `comments`.`autors`=`forum_posts`.`author`
		WHERE `comments`.`autors`=$id or `forum_posts`.`author`=$id
		order by `comments`.`time`, `forum_posts`.`time` desc Limit 7

Atgriež:

Unknown table 'comments'

Ilgi centos saprast, kas par vainu, nespēju atrast vainu.

Tabula 100% eksistē un ir pareizi uzrakstīta.

Varbūt kāds ar asāku aci un lielāku pieredzi var izpalīdzēt?

Jau iepriekš pateicos! :)

Edited by daviskrex
Link to comment
Share on other sites

 MySQL said: 
#1051 - Unknown table 'comments' 

Mēģināšu kaut ko uzzināt par šo #1051 errora kodu.

EDIT: Man izdevās palaist izķeksēšanu

		SELECT `comments`.*, `forum_posts`.* 
		FROM `comments`, `forum_posts`
		WHERE `comments`.`autors`=$id or `forum_posts`.`author`=$id
		order by `comments`.`time`, `forum_posts`.`time` desc Limit 7;

 

Nākošā problema:

Ir kolonna comments.type, kurā tiek norādīts komentāru tipa (news, blog ...), savukārt, forumam tāda nav, bet..

Nez kāpēc forums tiek uzrādīts kā blogs

 

ar print_r vispār murgs -

//FORUM_POSTS ROW
// TURKLĀT ŠIS POSTS IR AR USER ID 9, NEVIS 1 KĀ TAS RĀDA
Array ( 
[0] => 1 
[id] => 9 
[1] => 1 
[sub_id] => 1 
[2] => 1 
[autors] => 1 
[3] => lalalalļāāā 
[text] => yay trancmaizite^^ 
[4] => 12312 
[time] => 1276181432 
[5] => 127.0.0.1 
[ip] => 213.182.206.130 
[6] => blog 
[type] => forum 
[7] => 9 
[8] => yay trancmaizite^^ 
[9] => [title] => 
[10] => 9 
[author] => 9 
[11] => 1 
[topic_id] => 1 
[12] => 1 
[forum_id] => 1 
[13] => 10.06.10. 17:50:32 
[date] => 10.06.10. 17:50:32 
[14] => 1276181432 
[15] => 213.182.206.130 
[16] => 0 
[edited] => 0 
[17] => 0 
[edited_by] => 0 
[18] => 
[edit_time] => 
[19] => forum )

//COMMENTS ROW
Array ( 
[0] => 1 
[id] => 1
[1] => 1 
[sub_id] => 1 
[2] => 1 
[autors] => 1 
[3] => lalalalļāāā 
[text] =>:)
[4] => 12312 
[time] => 1276099496 
[5] => 127.0.0.1 
[ip] => 127.0.0.1 [6] => blog 
[type] => forum 
[7] => 1 
[8] =>:)
[9] => trancmaizīte 
[title] => trancmaizīte 
[10] => 1 
[author] => 1 
[11] => 1 
[topic_id] => 1 
[12] => 1 
[forum_id] => 1 
[13] => 09.06.10. 19:04:56 
[date] => 09.06.10. 19:04:56 
[14] => 1276099496 
[15] => 127.0.0.1 
[16] => 0 
[edited] => 0 
[17] => 0 
[edited_by] => 0 
[18] => 
[edit_time] => 
[19] => forum ) 

mysql> SELECT * FROM comments where autors=1;
+----+--------+--------+-----------------+-------+-----------+------+
| id | sub_id | autors | text            | time  | ip        | type |
+----+--------+--------+-----------------+-------+-----------+------+
|  1 |      1 |      1 | lalalal─╝─ü─ü─ü     | 12312 | 127.0.0.1 | blog |
+----+--------+--------+-----------------+-------+-----------+------+
1 row in set (0.10 sec)

mysql> SELECT * FROM forum_posts WHERE author=1;
+----+-----------+---------------+--------+----------+----------+---------------
-----+------------+-----------+--------+-----------+-----------+-------+
| id | text      | title         | author | topic_id | forum_id | date
    | time       | ip        | edited | edited_by | edit_time | type  |
+----+-----------+---------------+--------+----------+----------+---------------
-----+------------+-----------+--------+-----------+-----------+-------+
|  1 | <p>:)</p> | trancmaiz─½te  |      1 |        1 |        1 | 09.06.10. 19:
04:56 | 1276099496 | 127.0.0.1 |      0 |         0 |           | forum |
+----+-----------+---------------+--------+----------+----------+---------------
-----+------------+-----------+--------+-----------+-----------+-------+
1 row in set (0.00 sec)

		if(isset($comment['type']) and isset($comment['autors'])){
			$type = $comment['type'];
		}
		else{
			if(isset($comment['author']) and isset($comment['forum_id'])){
				$type = 'forum';
			}
			else {
				$type = NULL;
			}
		}
			if(isset($type) and !empty($type)){
				if($type == 'news'){
					$link = '';
				}
				else {
					$link = $type.'/';
				}
			       echo "<a href='".ROOT_PATH."/".$link.$comment['id']."/'>
						".trim_text($comment['text'], 50)." ".$type."
                                       </a>";

Edited by daviskrex
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...