tags:

views:

13

answers:

2

Hi All, 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&amp;u=$poster_id'&gt;&lt;/a&gt;$username&lt;/b&gt; Posted in \"<a href='http://microfusion.mine.nu/forums/viewtopic.php?$forum_id1&amp;t=$topic_id&amp;p=post_id#p$post_id'&gt;$topic_name\"&lt;/a&gt;&lt;br />";
//echo "RecPos.$toflash";

    //to test first before flash integration
echo "$username Posted in $topic_name<br />";

    }

    ?>
A: 
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
maggie
Thanx for the quick replay, When I use this code above I'm Back to a blank Screen :(, Man If i knew it was gonna be such a mission i would have gone with MySQL lol
banshee10000
TY, Now at least getting Error form Query: SELECT * FROM phpbb_posts ORDER BY post_time DESC LIMIT 15Notice: Undefined index: post_id in rec.php on line 25 Notice: Undefined index: topic_id in rec.php on line 26 Notice: Undefined index: forum_id in rec.php on line 27 Notice: Undefined index: poster_id in rec.php on line 28 Notice: Undefined index: post_time in rec.php on line 29 Fatal error: Function name must be a string in rec.php on line 34....
banshee10000
AH HA GOT it, Thank you So Much for your Help Will post Solution
banshee10000
+1  A: 

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

banshee10000