1 (edited by User33 2008-12-10 16:35)

Topic: db_seems_utf8() function error

If the posts table is empty, the function will send this error:

The error occurred on line 325 in E:\home\forums\admin\db_update.php

Database reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1 (Errno: 1064).

Because the resulting query is:

SELECT p.message, p.poster, t.subject, f.forum_name FROM punbb_posts AS p INNER JOIN punbb_topics AS t ON t.id = p.topic_id INNER JOIN punbb_forums AS f ON f.id = t.forum_id WHERE p.id >= LIMIT 1 

There is no 'id' to use.

So, my "fix" would be:

    if(!$min_id && !$max_id)
    {
        $result = $forum_db->query("SHOW TABLE STATUS LIKE '{$forum_db->prefix}posts'") or error(__FILE__, __LINE__);
        $table = $forum_db->fetch_assoc($result);

        return (substr($table['Collation'], 0, 4) == 'utf8') ? true : false;
    }

after

list($min_id, $max_id) = $forum_db->fetch_row($result);

I don't know if this will work on all db types.

Re: db_seems_utf8() function error

Thanks for report.

Garciat, what do you think about this fix?

Re: db_seems_utf8() function error

Yep, that's better.