Codigo Php para foro phpbb2

JmL
12 de Abril del 2006
Os propongo un reto, yo llevo 3 dias y no he conseguido sacar el codigo correcto, mi nivel de php no es muy avanzado, asi que aver si entre todos podeis ayudarme. Os voy a apsar un codigo, k me da el siguiente error:

[code]Bad $rs in GetInsertSQL. Connection or SQL invalid. Try using $connection->debug=true;[/code]

Ademas me tiene k insertar informacion en tres tablas de la base de datos (para el foro phpbb), pero en la ultima (phpbb_post_text) no me inserta nada ..... aver si somos capaces de sacar el codigo correcto... aki os dejo el completo que me da error :

[code]if ($_REQUEST['do'] == 'add_news_confirm')
{
$rs = $db->Execute("SELECT * FROM `sp_news` WHERE `id` = '-1'");
$record = array(
'title' => $_REQUEST['title'],
'author' => $_REQUEST['author'],
'section' => $_REQUEST['section'],
'intro' => $_REQUEST['intro'],
'text' => $_REQUEST['text'],
'date' => $_REQUEST['date'],
'newsimage' => $_REQUEST['newsimage']
);
$sql = $db->GetInsertSQL($rs, $record);
$db->Execute($sql);
$db->Execute("INSERT INTO phpbb_topics (forum_id,topic_title,topic_poster,topic_time,topic_views,topic_replies,topic_status,topic_type,topic_vote) VALUES ('1', '$_REQUEST[title]', '1', '$_REQUEST[date]',0,0,0,0,0)");
$result1 = $db->Execute("SELECT MAX(topic_id) as newID FROM phpbb_topics");

$rs = $db->Execute("SELECT * FROM `phpbb_topics` WHERE `topic_id` = '-1'");
$record = array();
$record['forum_id'] = '1';
$record['topic_title'] = $_REQUEST['title'];
$record['topic_poster'] = '1';
$record['topic_time'] = $_REQUEST['date'];
$record['topic_views'] = '0';
$record['topic_replies'] = '0';
$record['topic_status'] = '0';
$record['topic_type'] = '0';
$record['topic_vote'] = '0';
$sql = $db->GetInsertSQL($rs,$record);
$db->Execute("INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, post_time) VALUES ('. $topicID .', '1', '1', '$_REQUEST[date]')");
$result2 = $db->Execute("SELECT MAX(post_id) as newID FROM phpbb_posts");

$rs = $db->Execute("SELECT * FROM `phpbb_posts` WHERE `topic_id` = '-1'");
$record = array();
$record['topic_id'] = '. $topicID .';
$record['forum_id'] = '1';
$record['poster_id'] = '1';
$record['post_time'] = $_REQUEST['date'];
$sql = $db->GetInsertSQL($rs,$record);
$db->Execute("INSERT INTO phpbb_posts_text (post_id, post_subject, post_text) VALUES ('1', '$_REQUEST[title]', '$_REQUEST[intro]')");
$rs = $db->Execute("SELECT * FROM `phpbb_posts_text` WHERE `topic_id` = '-1'");
$record = array();
$record['post_id'] = 1;
$record['post_subject'] = $_REQUEST['title'];
$record['post_text'] = $_REQUEST['intro'];
$sql = $db->GetInsertSQL($rs,$record);
SPMessage('Success | News has been successfully added.', 'news.php');[/code]