kiote2th
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору пишу скрипт добавления сообщения function post_message($user_id, $forum_topic_id, $forum_id, $post_message) // добавляем пост { $current_time = time(); $topic_type = 0; $topic_vote = 0; $topic_status = 0; $user_ip = "c312dc2"; $bbcode_on = 1; $html_on = 0; $smilies_on = 0; $attach_sig = 0; $post_username = ""; $bbcode_uid = substr(md5(mt_rand()), 0, 10); $post_message = preg_replace('/<a href=\"([^"]+)\">([^<]+)<\/a>/','$2',$post_message); $post_message = str_replace('<','[',$post_message); $post_message = str_replace('>',']',$post_message); $sql = 'SELECT MAX(post_id) AS max_post_id FROM phpbb_posts'; $result = $this -> _select($sql); $topic_id = $result[0]['max_post_id']; $sql = "INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ('".$forum_topic_id."', '".$forum_id."','".$user_id."','' ,'".$current_time."', 'd5f23e2d', '', '1', '1', '0')"; $result = mysql_query($sql); // была транзакция if (!$result) { echo "error2: " . mysql_error($result).'<br>topic_id:'.$topic_id.'<br>foum_id'.$forum_id; return -1; } $sql = 'SELECT MAX(post_id) AS max_post_id FROM phpbb_posts_text'; $result = $this -> _select($sql); $post_id = $result[0]['max_post_id']+1; $sql = "INSERT INTO phpbb_posts_text (post_id, post_subject, bbcode_uid, post_text) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$post_message')"; $result = mysql_query($sql); if (!$result) { echo "error3: " . mysql_error($result); return -1; } $sql = "UPDATE phpbb_topics SET topic_first_post_id = $post_id, topic_last_post_id = $post_id WHERE topic_id = $topic_id"; $result = mysql_query($sql); if (!$result) { echo "error4: " . mysql_error($result); return -1; } else echo 'phpbb_topics<br>'; $sql = "UPDATE phpbb_forums SET forum_posts = forum_posts + 1, forum_last_post_id = $post_id, forum_topics = forum_topics + 1 WHERE forum_id = $forum_id"; $result = mysql_query($sql); if (!$result) { echo "error5: " . mysql_error($result); return -1; } $sql = "UPDATE phpbb_users SET user_posts = user_posts + 1 WHERE user_id = $user_id"; $result = mysql_query($sql); if (!$result) { echo "error6: " . mysql_error($result); return -1; } return $topic_id; } форум говорит "Темы, которую вы запросили, не существует." смотрю в таблицах - есть! помогите, что не так? уже крыша едет! |