Witam!


Mam pewien kod-skrypt, który po uruchomieniu powinien dokonać znaczne zmiany w bazie, jednak...nic się nie dzieje - zero błędów & zero zmian w bazie.

Możecie spojrzeć w kod i nakierować mnie na ew. błędy?

  1. <?php
  2. $idbota = $board_config['bot_id'];
  3. $urll = $board_config['server_name'];
  4. $pathh = $board_config['script_path'];
  5.  
  6. if ( isset($_POST['dalej']) )
  7. {
  8. $sql = "SELECT topic_id, topic_reason, forum_id, topic_action_date
  9. FROM " . TOPICS_TABLE . "
  10. WHERE topic_status = 1
  11. group by topic_id";
  12. if ( ! $result = mysql_query($sql) )
  13. while( $row = $db->sql_fetchrow($result) )
  14. {
  15. $topic_id = $row['topic_id'];
  16. $reason = $row['topic_reason'];
  17. $forum_id = $row['forum_id'];
  18. $topic_action_date = $row['topic_action_date'];
  19. }
  20. while ($row = mysql_fetch_assoc($result))
  21. {
  22.  
  23. $sql = "SELECT post_id, post_parent, post_order
  24. FROM " . POSTS_TABLE . "
  25. WHERE topic_id = $topic_id
  26. ORDER BY post_order";
  27. if ( !($result = $db->sql_query($sql)) )
  28. {
  29. message_die(GENERAL_MESSAGE, $lang['No_such_post']);
  30. }
  31. while ( $row = $db->sql_fetchrow($result) )
  32. {
  33. if ( $row['post_id'] == $post_data['post_parent'] )
  34. {
  35. $post_parent_order = $row['post_order'];
  36. $begin_new_parents = 1;
  37. }
  38.  
  39. if ( !$row['post_parent'] && !$post_parent_order )
  40. {
  41. $begin_new_parents = $order_last_parents = 0;
  42. $this_tree_parents = array();
  43. }
  44.  
  45. if ( $begin_new_parents )
  46. {
  47. if ( $row['post_parent'] )
  48. {
  49. $this_tree_parents[] = $row['post_parent'];
  50. }
  51. if ( $row['post_id'] == $post_data['post_parent'] || ($row['post_parent'] >= $post_data['post_parent'] && in_array($post_data['post_parent'], $this_tree_parents) ) )
  52. {
  53. $order_last_parents = $row['post_order'];
  54. }
  55. else
  56. {
  57. $max_order = ($order_last_parents) ? $order_last_parents : $row['post_order'];
  58. }
  59. }
  60. $max_order_all = $row['post_order'];
  61. }
  62. $max_order = $max_order_all;
  63. $post_order = $max_order + 1;
  64.  
  65. $sql = "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`) VALUES (".$db->sql_nextid().", '".$topic_id."', '".$forum_id."', '".$idbota."', '".$topic_action_date."', '0', '', '1', '1', '1', '1', '0', '0', '0', '', '0', '0', '0', 'NULL', '1', '0', '0', '0', ".$post_order.")";
  66. {
  67. message_die(CRITICAL_ERROR, 'Error1');
  68.  
  69. }
  70.  
  71. $sql = "INSERT INTO ".POSTS_TEXT_TABLE." (`post_id`, `bbcode_uid`, `post_subject`, `post_text`) VALUES (".$db->sql_nextid().", '0', '', '".str_replace("\'", "''", sprintf($board_config['bot_message'], $reason))."')";
  72. {
  73. message_die(CRITICAL_ERROR, 'Error2');
  74. }
  75. $sql = "SELECT post_id
  76. FROM " . POSTS_TABLE . "
  77. WHERE forum_id = $forum_id
  78. AND topic_id = $topic_id
  79. AND poster_id = $idbota";
  80. if ( !($result = $db->sql_query($sql)) )
  81. {
  82. message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
  83. }
  84. $result = $db->sql_query($sql);
  85. while( $row = $db->sql_fetchrow($result) )
  86. {
  87. $post_id = $row['post_id'];
  88. }
  89. $sql = "UPDATE " . FORUMS_TABLE . "
  90. SET forum_last_post_id = $post_id
  91. WHERE forum_id = $forum_id";
  92. if ( !($result = $db->sql_query($sql)) )
  93. {
  94. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  95. }
  96.  
  97. $sql = "UPDATE " . TOPICS_TABLE . "
  98. SET topic_last_post_id = $post_id
  99. WHERE topic_id = $topic_id";
  100.  
  101. if ( !($result = $db->sql_query($sql)) )
  102. {
  103. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  104. }
  105.  
  106. $sql = "SELECT user_posts
  107. FROM " . USERS_TABLE . "
  108. WHERE user_id = $idbota";
  109. $result = $db->sql_query($sql);
  110. while( $row = $db->sql_fetchrow($result) )
  111. {
  112. $posts_bot = $row['user_posts'];
  113. }
  114.  
  115. $postss_bot = $posts_bot + 1;
  116.  
  117.  
  118. $sql = "UPDATE " . USERS_TABLE . "
  119. SET user_posts = $postss_bot
  120. WHERE user_id = $idbota";
  121.  
  122. if ( !($result = $db->sql_query($sql)) )
  123. {
  124. message_die(GENERAL_ERROR, 'jakis errorek', '', __LINE__, __FILE__, $sql);
  125. }
  126. }
  127. }
  128. ?>


Pozdr.