Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Błąd w składni
Forum PHP.pl > Forum > PHP
Mody23
Witam!

Co tutaj może być nie tak? Klamerki sprawdzałem i wszystko jest ok.

Parse error: syntax error, unexpected T_ELSE

  1. if ( ! $sql = mysql_query("SELECT * FROM " . POSTS_TABLE . " WHERE topic_id = $moved_topics_ids_imp AND post_reason_mod = 0 AND poster_id = $idbota limit 1") )
  2. {
  3.  
  4. $num = mysql_num_rows($sql);
  5.  
  6. if ( $num )
  7. {
  8.  
  9.  
  10. if ( !$db->sql_query("INSERT INTO ".POSTS_TABLE." (`post_id`, `topic_id`, `forum_id`, `poster_id`, `post_time`, `poster_ip`, `post_username`, `enable_bbcode`, `enable_html`, `enable_smilies`, `enable_sig`, `post_edit_time`, `post_edit_count`, `post_attachment`, `user_agent`, `post_icon`, `post_expire`, `reporter_id`, `post_marked`, `post_approve`, `poster_delete`, `post_edit_by`, `post_parent`, `post_order`, `post_reason_mod`) VALUES (".$db->sql_nextid().", '".$moved_topics_ids_imp."', '".$new_forum_id."', '".$idbota."', '".CR_TIME."', '0', '', '1', '0', '1', '1', '0', '0', '0', '', '0', '0', '0', '0', '1', '0', '0', '0', '".$post_order."', '2')") )
  11.  
  12. {
  13. message_die(CRITICAL_ERROR, 'Error1');
  14. }
  15.  
  16. if ( !$db->sql_query("INSERT INTO ".POSTS_TEXT_TABLE." (`post_id`, `bbcode_uid`, `post_subject`, `post_text`) VALUES (".$db->sql_nextid().", '0', '', '".str_replace("\'", "''", sprintf($lang['bot_message_change'], $forum_name_old, $forum_name_new))."')") )
  17.  
  18. {
  19. message_die(CRITICAL_ERROR, 'Error2');
  20. }
  21. $sql = "SELECT forum_posts
  22. FROM " . FORUMS_TABLE . "
  23. WHERE forum_id = $new_forum_id";
  24. if ( !($result = $db->sql_query($sql)) )
  25. {
  26. message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
  27. }
  28. $result = $db->sql_query($sql);
  29. while( $row = $db->sql_fetchrow($result) )
  30. {
  31. $forum_posts = $row['forum_posts'];
  32. }
  33.  
  34. $forum_postss = $forum_posts + 1;
  35.  
  36. $sql = "SELECT topic_replies
  37. FROM " . TOPICS_TABLE . "
  38. WHERE topic_id =$moved_topics_ids_imp";
  39. if ( !($result = $db->sql_query($sql)) )
  40. {
  41. message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
  42. }
  43. $result = $db->sql_query($sql);
  44. while( $row = $db->sql_fetchrow($result) )
  45. {
  46. $topic_replies = $row['topic_replies'];
  47. }
  48.  
  49. $topic_repliess = $topic_replies + 1;
  50.  
  51. $sql = "SELECT post_id
  52. FROM " . POSTS_TABLE . "
  53. WHERE forum_id = $new_forum_id
  54. AND topic_id = $moved_topics_ids_imp
  55. AND poster_id = $idbota";
  56. if ( !($result = $db->sql_query($sql)) )
  57. {
  58. message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
  59. }
  60. $result = $db->sql_query($sql);
  61. while( $row = $db->sql_fetchrow($result) )
  62. {
  63. $post_id = $row['post_id'];
  64. }
  65.  
  66. $sql = "UPDATE " . TOPICS_TABLE . "
  67. SET topic_last_post_id = $post_id
  68. WHERE topic_id = $moved_topics_ids_imp";
  69.  
  70. if ( !($result = $db->sql_query($sql)) )
  71. {
  72. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  73. }
  74.  
  75. $sql = "UPDATE " . FORUMS_TABLE . "
  76. SET forum_last_post_id = $post_id
  77. WHERE forum_id = $new_forum_id";
  78.  
  79. if ( !($result = $db->sql_query($sql)) )
  80. {
  81. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  82. }
  83.  
  84. $sql = "UPDATE " . TOPICS_TABLE . "
  85. SET topic_replies = $topic_repliess
  86. WHERE topic_id = $moved_topics_ids_imp";
  87. if ( !($result = $db->sql_query($sql)) )
  88. {
  89. message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
  90. }
  91.  
  92. $sql = "UPDATE " . FORUMS_TABLE . "
  93. SET forum_posts = $forum_postss
  94. WHERE forum_id = $new_forum_id";
  95. if ( !($result = $db->sql_query($sql)) )
  96. {
  97. message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
  98. }
  99.  
  100. $sql = "SELECT user_posts
  101. FROM " . USERS_TABLE . "
  102. WHERE user_id = $idbota";
  103. $result = $db->sql_query($sql);
  104. while( $row = $db->sql_fetchrow($result) )
  105. {
  106. $posts_bot = $row['user_posts'];
  107. }
  108.  
  109. $postss_bot = $posts_bot + 1;
  110.  
  111.  
  112. $sql = "UPDATE " . USERS_TABLE . "
  113. SET user_posts = $postss_bot
  114. WHERE user_id = $idbota";
  115.  
  116. if ( !($result = $db->sql_query($sql)) )
  117. {
  118. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  119. }
  120.  
  121. $sql = "SELECT topic_last_post_id
  122. FROM " . TOPICS_TABLE . "
  123. WHERE topic_id = $moved_topics_ids_imp";
  124. $result = $db->sql_query($sql);
  125. while( $row = $db->sql_fetchrow($result) )
  126. {
  127. $lastt_post = $row['topic_last_post_id'];
  128. }
  129. }
  130. }
  131.  
  132. else if ( ! $sql = mysql_query("SELECT post_id FROM " . POSTS_TABLE . " WHERE topic_id = $moved_topics_ids_imp AND post_reason_mod = 2 AND poster_id = $idbota limit 1") )
  133. {
  134. $result = $db->sql_query($sql);
  135. while( $row = $db->sql_fetchrow($result) )
  136. {
  137. $postt_idd = $row['post_id'];
  138. }
  139.  
  140.  
  141. $numm = mysql_num_rows($sql);
  142.  
  143. else if ( $numm )
  144. {
  145. $sql = "UPDATE " . POSTS_TEXT_TABLE . "
  146. SET post_text = '".str_replace("\'", "''", sprintf($lang['bot_message_change'], $forum_name_old, $forum_name_new))."'
  147. WHERE post_id = $postt_idd";
  148. if ( !($result = $db->sql_query($sql)) )
  149. {
  150. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  151. }
  152. }
  153. }
ADeM
Łatwiej by było jakbyś podał jaki błąd dostajesz i w której linijce...
Mody23
Błąd w składni ELSE, ta linia:

  1. else if ( ! $sql = mysql_query("SELECT post_id FROM " . POSTS_TABLE . " WHERE topic_id = $moved_topics_ids_imp AND post_reason_mod = 2 AND poster_id = $idbota limit 1") )
wizu
I dobrze, Ci wywala błąd. Przecież ten else nie odnosi się do żadnego if-a.

Zauważ, że jeśli Twój if z pierwszej linijki będzie prawdziwy, to wykona się linijka druga,.
Cała reszta objęta klamrami począwszy od linii 3 wykona się zawsze, bo do if-a "należy" tylko druga linijka.
Usuń drugą linię i będzie ok.
Daiquiri
Forum to nie parser. Zamykam.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.