我需要快速帮助,而不是使用mySQL我的phpbb3论坛使用SQlite 2,一个普通的“database.db文件,它是从一个notepad.txt文件手动创建的,然后由phpbb3填充”我需要帮助访问该SQlite中的数据2数据库而不是MySQL。
当我运行此脚本时,我得到了回音:最近的帖子(位于第3行) 但没有别的
我是一个完整的PHP菜鸟,所以Plz帮助,我已经有一个星期了,现在没有运气
最终我想在我的网站上显示Phpbb3之外的html支持的Adobe Flash Dynamic txt框中的15个最新帖子
enter code here
<?php
$db = sqlite_open("Mydatabasenamehere.db", 0666, $sqliteerror);
echo "Recent Posts<p />";
$recent = sqlite_query($db, "SELECT * FROM * phpbb_posts ORDER BY post_time DESC LIMIT 15");
while ($recent_row = sqlite_fetch_all($recent, SQLITE_ASSOC))
{
// get data
$post_id = $recent_row['post_id'];
$topic_id = $recent_row['topic_id'];
$forum_id = $recent_row['forum_id'];
$poster_id = $recent_row['poster_id'];
$post_time = $recent_row['post_time'];
// get topic name
$topic_name = sqlite_query($db, "SELECT topic_title FROM phpbb_topics WHERE topic_id='$topic_id'");
$topic_name = sqlite_fetch_all($topic_name);
$topic_name = $topic_name('topic_title');
// get username
$username = sqlite_query($db, "SELECT username FROM phpbb_users WHERE user_id='$poster_id'");
$username = sqlite_fetch_all($username);
$username = $username['username'];
//var for flash
//$toflash = "<b><a href='http://microfusion.mine.nu/forums/memberlist.php?mode=viewprofile&u=$poster_id'></a>$username</b> Posted in \"<a href='http://microfusion.mine.nu/forums/viewtopic.php?$forum_id1&t=$topic_id&p=post_id#p$post_id'>$topic_name\"</a><br />";
//echo "RecPos.$toflash";
//to test first before flash integration
echo "$username Posted in $topic_name<br />";
}
?>
答案 0 :(得分:1)
所以在Maggie的帮助下,我设法解决了这个问题:
enter code here
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$db = sqlite_open("MyDATABASENAMEHERE.db", 0666, $sqliteerror)
or die($sqliteerror);
echo "<p>Recent Posts</p>";
$sql = "SELECT * FROM phpbb_posts ORDER BY post_time DESC LIMIT 15";
echo "<p>Query: " . $sql . "</p>";
$recent = sqlite_query($db, $sql)
or die(sqlite_error_string(sqlite_last_error()));
while ($recent_row = sqlite_fetch_array($recent, SQLITE_ASSOC))
{
// get data
$post_id = $recent_row['post_id'];
$topic_id = $recent_row['topic_id'];
$forum_id = $recent_row['forum_id'];
$poster_id = $recent_row['poster_id'];
$post_time = $recent_row['post_time'];
// get topic name
$topic_name = sqlite_query($db, "SELECT topic_title FROM phpbb_topics WHERE topic_id='$topic_id'");
$topic_name = sqlite_fetch_array($topic_name);
$topic_name = $topic_name["topic_title"];
// get username
$username = sqlite_query($db, "SELECT username FROM phpbb_users WHERE user_id='$poster_id'");
$username = sqlite_fetch_array($username);
$username = $username['username'];
echo "'$username' Posted in '$topic_name'<br />";
}
?>
我不得不将SQlite更改为“Fetch_array”而不是“all”或“string” 希望这也有助于其他人
答案 1 :(得分:0)
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$db = sqlite_open("Mydatabasenamehere.db", 0666, $sqliteerror)
or die($sqliteerror);
echo "<p>Recent Posts</p>";
$sql = "SELECT * FROM phpbb_posts ORDER BY post_time DESC LIMIT 15";
echo "<p>Query: " . $sql . "</p>";
$recent = sqlite_query($db, $sql)
or die(sqlite_error_string(sqlite_last_error()));
<?php
之后)or die($sqliteerror);