Firefox PHP

CMS integration problem: Table '...forum_user_newflags' doesn't exist

Posted by jsjwilson 
CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 17, 2007 06:59PM
Hello,

I have been using phorum 5.1.15 succesfully for almost 9 months with few problems. It was previously running with a fairly simple template that had been accomodated into the phorum templating system (header.tpl etc). However, I have been trying to develop the website recently, and am using a CMS called "snews", which I have found is a very light, quick, article publishing script that would allow more people other than myself to develop the appearence of the site.

I had already succesfully placed a "last post" feed from the phorum on the home page. At first, adapting the header.tpl and footer.tpl to accomodate calling the snews script seemed to have worked very well. However, then I noticed that, only when logged in, and reading an actual thread (i.e. not a menu), I got the following message:

Table '.....forum_user_newflags' doesn't exist: SELECT count(*) FROM forum_user_newflags WHERE user_id=2 AND forum_id=2

I'm not sure what this means, and how to prevent it. The script footer, is not parsing below the main div that contains the forum either.

I'd sure appreciate any help or ideas.

Thank you very much, and cheers for developing such a great forum!

jamie



Edited 1 time(s). Last edit at 01/19/2007 06:02PM by jsjwilson.
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 17, 2007 07:19PM
The CMS probably uses its own database and switches the active Phorum database connection to that CMS database. That can be a reason for the table not being found. Am I right that Phorum and the CMS use their own MySQL database?


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 18, 2007 12:09PM
Yes you are right.

This is the code from the header.tpl

<EDIT>See edit below</EDIT>

snews.php defines a different db within the same host as that used for the phorum and opens it.

The footer:

<EDIT> Apologies, but I had to remove the code because after I put it up my site got hacked,
apparently by someone hacking snews, identifying it through metanames I had posted above </EDIT>



Edited 2 time(s). Last edit at 01/19/2007 06:02PM by jsjwilson.
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 18, 2007 02:01PM
Cheers for the help btw, its very much appreciated! Is the db the problem?
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 19, 2007 03:03AM
Yes, the problem lies in the way your cms handles database connections. Phorum does not asume it's the only one accessing the database, but the cms will. The cms kind of hijacks Phorum's db connection and points it at the CMS database.

For more info see thiis support thread.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 21, 2007 07:39PM
Hi Maurice,

I read the thread you advised. First off, I added the @ in phorum_db_check_connection:

$conn = @phorum_db_mysql_connect();

This did not tackle the problem. In mysql.php, I made it select the db:

function phorum_db_mysql_connect(){
    $PHORUM = $GLOBALS["PHORUM"];

    static $conn;
    if (empty($conn)){
        $conn = mysql_connect($PHORUM["DBCONFIG"]["server"], $PHORUM["DBCONFIG"]["user"], $PHORUM["DBCONFIG"]["password"], true);
    }
        mysql_select_db($PHORUM["DBCONFIG"]["name"], $conn);
    return $conn;
}

This has solved the issue in terms of appearence, but I read in the thread that this isn't ideal and is resource intensive.

a) The 4th parameter (true) is already being used in the mysql connect calls (I didn't need to add this unless I am looking in the wrong place). Without a deliberate db select, as above, the error I previously described is still present. How should I be tackling this?

b) If what I've done is acceptable, should I make this change in any other file other than mysql.php?

Forgive an ignorant peasant please!!

Cheers,

Jamie
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 21, 2007 07:54PM
Did you change Phorum code or your cms's code?

I think the CMS is the buggy one...

---
-=[ Panu ]=-
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 21, 2007 08:43PM
Panu is right. It's the CMS that is hijacking Phorum's db connection and pointing it at a different database. The Phorum code uses its own connection $conn in all places. So if you want to change Phorum to work around this problem, then all you can do is add the extra select db call to point the database connection back at the Phorum database.

Putting a "@" in front of a command will never fix a problem. It's only task is to tell PHP to ignore any error output from that command. So it's only useful for those cases where a command could return an error message, but where errors can be safely ignored (for example because follow up code will shown a clean error message in case something went wrong).


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 22, 2007 04:52AM
1) I accept you must be correct, but could you explain to me why it is that everything except the bottom menu bar of the forum thread when logged in parses without a problem (after it has called the CMSs DB in the header template.

2) Is there an intrinsic problem using the extra db select call?

Thanks for the help. Its very much appreciated.

Jamie
Re: CMS integration problem: Table '...forum_user_newflags' doesn't exist
January 22, 2007 05:05AM
1) Most of the database processing that Phorum needs is done before the header.tpl is even loaded, so gathering of information from the database will work up to the point where the header.tpl is loaded. Only database calls that are made after loading the header template will fail.

2) There no problem with that, but if you're using the CMS only for providing a header and footer, then you could also move a db select call to the template, to re-select the Phorum database after the CMS code was loaded. That way, you won't have to call it on every request.

In all, I would not worry to much about the extra select db calls, unless you're on a system where you really need to squeeze out every bit of performance that you can.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login