Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 02:05:45 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155476 Posts in 21708 Topics by 7734 Members
Latest Member: rofroodoOvego
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Problem with Code page using Vincent02 template  (Read 586 times)
rudivs

Offline Offline

Posts: 1


« on: December 30, 2008, 08:58:15 PM »

Using the Vincent02 template, I get an error when I try to use database connections in a Code type page. For example, if I use only the following code, it causes the page to display without a menu, and on a grey background.

Code:
require 'DB.php';
$db = DB::connect('mysql://root@localhost/SpmnData');

In website baker 2.6.7 it also gave the error "Call to a member function numRows() on a non-object", pointing to line 337 in framework/class.frontend.php. That line is "$if($query_menu->numRows() > 0) {" in the function show_menu().

Can anyone help me to debug this? Other templates don't seem to have the same problem. I love the vincent02 template and I'd hate to have to use another one.
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #1 on: December 30, 2008, 09:08:27 PM »

Maybe give the require "DB.php" a complete path, currently the webserver is looking for it where the page is located. By checking the server logs you should see this as well.

Additionally you will need to close the database connection at the end and reopen the WB connection.

If I am not misstaken somebody posted a Database connection Module somewhere ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

jmarco

Offline Offline

Posts: 3


« Reply #2 on: June 12, 2009, 10:57:55 AM »

I am having quite a similar problem. I traced the code and found out that adding a line

Code:
$database->connect();

at the end of my code will fix it.

It seems that only one connection can be open at a time so you need to close the one you opened and reopen WB's connection.

It seems that the crashing instruction is in file filter-routines.php line 35 which is a query to the WB db. I wonder if it would not be a good idea to ensure that the WB db keeps connected after showing some processed output by adding this line in file \wb\index.php (which is where the initial call which causes the crash is originated) at line 99:

Code:
93:    if(function_exists('filter_frontend_output')) {
94:        // store output in variable for filtering
95:        @ob_start();
96:        require(WB_PATH.'/templates/'.TEMPLATE.'/index.php');        
97:        $frontend_output = ob_get_contents();        
98:        @ob_end_clean();    
99:        // Ensure we are connected to WB's db before further processing!    
100:        $database->connect();
        // Display the filtered output on the frontend                
        echo filter_frontend_output($frontend_output);
        die;
    }

Could someone confirm this is correct?

  Thanks!
« Last Edit: June 12, 2009, 11:08:01 AM by jmarco » Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #3 on: June 12, 2009, 06:55:21 PM »

The "1 connection" is indeed right. You need to close every connection you open. I think you should even close and re-open the WB connection, at least if you are having trouble.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

jmarco

Offline Offline

Posts: 3


« Reply #4 on: June 15, 2009, 10:55:02 AM »


  Thanks, Klaus, that solves my doubts. I am managing well by now with the quick fix in index.php that I posted.

  Have a nice day!
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!