Trying to add posts connecting directly via MYSQL

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.
Locked
rulzy
Registered User
Posts: 1
Joined: Mon Aug 23, 2010 5:43 pm

Trying to add posts connecting directly via MYSQL

Post by rulzy »

Hello I'm coding a PHP script that connects to mysql phpBB database and add new posts directrly, everything seems to be O.K. but I have a little problem: when I search for posts the posts addes with my soft doesnt appear in search results, any idea what could be? I did two INSERT, one to the table phpbb_posts and the other to phpbb_topics, finally an UPDATE to phpbb_forums, perhaps I´m missing to UPDATE or INSERT something in another table or I´m missing a column in the tables I´m working?

Here the querys:

Code: Select all

$sql_phpbb_posts="INSERT INTO phpbb_posts (post_id, topic_id, forum_id, poster_id, icon_id, poster_ip, post_time, post_approved, ";
         $sql_phpbb_posts.="post_reported, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject, ";  
         $sql_phpbb_posts.="post_text, post_checksum, post_attachment, bbcode_bitfield, bbcode_uid, post_postcount, post_edit_time, ";
  	     $sql_phpbb_posts.="post_edit_reason, post_edit_user, post_edit_count, post_edit_locked)";
	     $sql_phpbb_posts.=" VALUES ('".$rand."','".$rand."','".$c."','2','0','0','".$fecha."','1',";
		 $sql_phpbb_posts.="'0','1','1','1','1','','".$titulo."','".$post."','','0','','','1','0','','0','0','0')";

Code: Select all

$sql_phpbb_topics="INSERT INTO phpbb_topics (topic_id, forum_id, icon_id, topic_attachment, topic_approved, topic_reported, ";
		 $sql_phpbb_topics.="topic_title, topic_poster, topic_time, topic_time_limit, topic_views, topic_replies, topic_replies_real, ";
		 $sql_phpbb_topics.="topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, ";
		 $sql_phpbb_topics.="topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, ";
		 $sql_phpbb_topics.="topic_last_post_subject, topic_last_post_time, topic_last_view_time, topic_moved_id, topic_bumped, ";
		 $sql_phpbb_topics.="topic_bumper, poll_title, poll_start, poll_length, poll_max_options, poll_last_vote, poll_vote_change, topic_url)";
		 $sql_phpbb_topics.=" VALUES ('".$rand."','".$c."','0','0','1','0','".$titulo."','2','".$fecha."','0','0','0','0','0','0','0','Judy', ";
		 $sql_phpbb_topics.="'AA0000','0','0','Judy', 'AA0000', '',  '".$fecha."',  '0',  '0',  '0',  '0',  '',  '0',  '0',  '1',  '0',  '0', '')"; 

Code: Select all

$sql_phpbb_forums="UPDATE phpbb_forums SET forum_posts='".$cant_posts."', forum_topics='".$cant_topics."', ";
		 $sql_phpbb_forums.="forum_last_post_id='".$rand."', forum_last_poster_id='2', forum_last_post_subject='".$titulo."', ";
		 $sql_phpbb_forums.="forum_last_post_time='".$fecha."', forum_last_poster_name='Judy', forum_last_poster_colour='AA0000', forum_topics_real='".$cant_topics."' WHERE forum_id='".$c."' LIMIT 1"; 



Thank you

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: Trying to add posts connecting directly via MYSQL

Post by A_Jelly_Doughnut »

Hi,

This is really a topic for the MOD Writer's forum at the main board :)

You are definitely missing things. The only way to be sure you preserve the data integrity is to use the posting API, aka http://wiki.phpbb.com/display/DEV/Submit+post
A_Jelly_Doughnut

Locked