Topic: punbb++ problem with sqlite on Win2000

I've just installed punbb++ on windows 2000 with the sqlite db option. installation went well. but when I go to the first page there is no forum name, just blank.

So I investigated whether the problem is in sqlite db file or the code, I found it with the code. there is nothing wrong with sqlite db file.

is there any who tried the same?

Re: punbb++ problem with sqlite on Win2000

Which php version do you use? There is different versions of sqlite in them so the sqlite support only works with php 5 beta 2. Rickard has written another sqlite class for 1.2 though. I think that one works better. Only problem is, it's not released yet ;)

3 (edited by jacobswell 2004-05-02 20:20)

Re: punbb++ problem with sqlite on Win2000

I found why. it's not the php version problem. it's sqlite problem.

let's see the problem. for instance, we can see this code in index.php

$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, 
f.forum_desc, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, 
f.last_poster, f.closed, f.locked FROM '.$db->prefix.'categories AS c INNER 
JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id'.$extra_sql.' 
ORDER BY c.disp_position, c.id, f.disp_position') 
or error('Unable to fetch category/forum list', 
__FILE__, __LINE__, $db->error());

and if database is sqlite, it wll return array which keys are cid, c.cat_name....
if mysql, we can get array wich keys are cid, cat_name...

and we are accustomed to use mysql so the next code is this :

while ($cur_forum = $db->fetch_assoc($result))
{
    if ($cur_forum['cid'] != $cur_category)    // A new category since last iteration?
    {

?>
    <tr>
        <td class="puncon3" colspan="6"><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></td>
    </tr>
<?php

Do you see the problem now? sqlite returns array which keys are 'cid', 'c.cat_name'... so there is no data whose key is 'cat_name'. so blank catalog name ....

actually it's not sqlite problem but php_sqlite problem that cannot handle that, I think. or we have to change like "c.cat_name as cat_name"... smile

Re: punbb++ problem with sqlite on Win2000

Yes, I know. It's an SQLite problem. It works like that. But the version bundled with php 5 didn't.

Re: punbb++ problem with sqlite on Win2000

Here's the function in the SQLite DB class from 1.2. It should probably work with Janssons DB class as well:

function fetch_assoc($query_id = 0)
{
    if (!$query_id)
        $query_id = $this->query_result;

    if ($query_id)
    {
        $this->row = @sqlite_fetch_array($query_id, SQLITE_ASSOC);

        if ($this->row)
        {
            // Horrible hack to get rid of table names and table aliases from the array keys
            while (list($key, $value) = @each($this->row))
            {
                if ($key{1} == '.')
                {
                    unset($this->row[$key]);
                    $key = substr($key, 2);
                    $this->row[$key] = $value;
                }
            }

            ++$this->row_num[$query_id];
        }

        return $this->row;
    }
    else
        return false;
}
"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: punbb++ problem with sqlite on Win2000

Great thanks, friends. smile