0
votes

I need help fast, instead of using mySQL my phpbb3 forum uses SQlite 2, a normal "database.db file that was manually created from a notepad.txt file then populated by phpbb3" I need help Accessing the data within that SQlite 2 database instead of MySQL.

when I run this Script I get echo: Recent Posts (located on line3) but nothing else

I'm a complete noob with PHP so Plz Help, I have been at it for 1 week now with no Luck

Ultimately I wanna Display the 15 most recent posts in a Adobe Flash Dynamic txt box with html support outside of Phpbb3 on my website

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 />";

    }

    ?>
2
Could you please post the html output from your script? - kskjon

2 Answers

1
votes

So With Maggie's help I've managed to sort this out:

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 />";

}

?>

I had to change SQlite to "Fetch_array" instead of "all" or 'string" Hope this Helps others too

0
votes
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()));
  1. enable error reporting (on top of the script, just after <?php)
  2. if there is still an white page check if you have access to error-log file
  3. check if sqlite_open was successful or die($sqliteerror);
  4. debug query
  5. call sqlite_error_string after every sqlite_query