Error

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Error

Post by Aishah » Thu Jul 10, 2008 11:04 am

Hello,

There is somenting very wrong with my forum.

I was trying to make a forum a subforum of another and this came up:

Code: Select all

General Error
SQL ERROR [ mysql4 ]

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 'AND right_id >' at line 4 [1064]

SQL

UPDATE phpbb_forums SET right_id = right_id - 2, forum_parents = '' WHERE left_id < AND right_id > 

BACKTRACE


FILE: includes/db/mysql.php
LINE: 158
CALL: dbal_mysql->sql_error()

FILE: includes/acp/acp_forums.php
LINE: 1281
CALL: dbal_mysql->sql_query()

FILE: includes/acp/acp_forums.php
LINE: 1209
CALL: acp_forums->move_forum()

FILE: includes/acp/acp_forums.php
LINE: 176
CALL: acp_forums->update_forum_data()

FILE: includes/functions_module.php
LINE: 471
CALL: acp_forums->main()

FILE: adm/index.php
LINE: 74
CALL: p_master->load_active()
Also, when I'm trying to manage the forums from the admin cp, they are all jumbling up and making their own parent categroies etc. when I'm trying to change them.

Thanks, Kind regards.

User avatar
jimdunn
Registered User
Posts: 1570
Joined: Tue Mar 25, 2008 11:49 am
Location: Australia

Re: Error

Post by jimdunn » Thu Jul 10, 2008 11:10 am

The problems you are describing look a bit like they could be caused by some damage to the forum "tree" in your forums table. I'm not saying it is definitely your issue, but the symptoms look similar.

There have been a couple of recent topics where this sort of thing has been solved by running a script to rebuild that tree.

Before I give you a link to the script, I'm going to stress that you should backup your database before attempting this solution. There is a possibility that the script could make your situation worse, so you need a database backup to restore to if that happens.

If you don't know how to backup your database PLEASE post back and ask for instructions to do that before running this script.

Note that I am talking about backing up your database - not your forum files - the 2 things are distinctly different.

That being said, here is a link to the script, and instructions to run it:
http://www.phpbb.com/community/viewtopi ... 5#p5975935

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:15 am

How do I backup my database?

User avatar
jimdunn
Registered User
Posts: 1570
Joined: Tue Mar 25, 2008 11:49 am
Location: Australia

Re: Error

Post by jimdunn » Thu Jul 10, 2008 11:22 am

2) Exporting Database.
2.a. Load into phpMyAdmin.
2.b. Select your database.
2.c. Click the tab "export".
2.d. Once on the "export page", you will see numerous options in different boxes. Make sure that:
- All the tables are selected if not, click "Select All"
- Make sure the output is SQL, if not click the radio button SQL
- In the "Structure" box, check the box next to "Add DROP TABLE"

Download:
- Check the box "Save as file"
- Choose your compression, none
- Click Go.
- You will get a download file, save to your desktop (Or chosen destination)
Taken from:
http://www.phpbb.com/kb/article/moving- ... phpmyadmin

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:30 am

Hello,

Is there anyway to know which one of the database names is the one for my current forum? because I have two for the forum and one belongs to the old forum I had (we think) which still remains.

Kind regards.

User avatar
jimdunn
Registered User
Posts: 1570
Joined: Tue Mar 25, 2008 11:49 am
Location: Australia

Re: Error

Post by jimdunn » Thu Jul 10, 2008 11:33 am

Yes

Look in the config.php file in the folder on your server which contains the forum in question.

Code: Select all

$dbname =

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:36 am

Thank you. So I can delete the other one which I don't use?

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:38 am

Now that I've backed it up, I name the file fixtree.php ?

User avatar
jimdunn
Registered User
Posts: 1570
Joined: Tue Mar 25, 2008 11:49 am
Location: Australia

Re: Error

Post by jimdunn » Thu Jul 10, 2008 11:39 am

Aishah wrote:Thank you. So I can delete the other one which I don't use?
Well, yes if you don't use it, you can.

But be very certain it is an unused database before you do that - if you're not sure just leave it - it won't do any harm.

Because of the type of person I am I'd probably back it up first if I was going to delete it - you never know ;)

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:43 am

Thanks.

User avatar
jimdunn
Registered User
Posts: 1570
Joined: Tue Mar 25, 2008 11:49 am
Location: Australia

Re: Error

Post by jimdunn » Thu Jul 10, 2008 11:44 am

Aishah wrote:Now that I've backed it up, I name the file fixtree.php ?
What file ?

The backup file you name anything you like - maybe backup.sql
You only need it if you need to restore the database.

fixtree.php is the script I linked you to.
You copy that code from the linked post into a new file and call it fixtree.php

It might be worth taking a little time to read the instructions again if you're confused :)

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:46 am

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: index.php,v 1.176 2007/10/05 14:30:06 acydburn Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');

recalc_btree('forum_id' , FORUMS_TABLE);
echo "Done";

function recalc_btree($sql_id, $sql_table, $module_class = '')
{
    global $db;

    if (!$sql_id || !$sql_table)
    {
        return;
    }

    $sql_where = ($module_class) ? " WHERE module_class = '" . $db->sql_escape($module_class) . "'" : '';

    // Reset to minimum possible left and right id
    $sql = "SELECT MIN(left_id) as min_left_id, MIN(right_id) as min_right_id
        FROM $sql_table
        $sql_where";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);

    $substract = (int) (min($row['min_left_id'], $row['min_right_id']) - 1);

    if ($substract > 0)
    {
        $sql = "UPDATE $sql_table
            SET left_id = left_id - $substract, right_id = right_id - $substract
            $sql_where";
        $db->sql_query($sql);
    }

    $sql = "SELECT $sql_id, parent_id, left_id, right_id
        FROM $sql_table
        $sql_where
        ORDER BY left_id ASC, parent_id ASC, $sql_id ASC";
    $f_result = $db->sql_query($sql);

    while ($item_data = $db->sql_fetchrow($f_result))
    {
        if ($item_data['parent_id'])
        {
            $sql = "SELECT left_id, right_id
                FROM $sql_table
                $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
                    $sql_id = {$item_data['parent_id']}";
            $result = $db->sql_query($sql);

            if (!$row = $db->sql_fetchrow($result))
            {
                $sql = "UPDATE $sql_table SET parent_id = 0 WHERE $sql_id = " . $item_data[$sql_id];
                $db->sql_query($sql);

                continue;    
            }
            $db->sql_freeresult($result);

            $sql = "UPDATE $sql_table
                SET left_id = left_id + 2, right_id = right_id + 2
                $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
                    left_id > {$row['right_id']}";
            $db->sql_query($sql);

            $sql = "UPDATE $sql_table
                SET right_id = right_id + 2
                $sql_where " . (($sql_where) ? 'AND' : 'WHERE') . "
                    {$row['left_id']} BETWEEN left_id AND right_id";
            $db->sql_query($sql);

            $item_data['left_id'] = $row['right_id'];
            $item_data['right_id'] = $row['right_id'] + 1;
        }
        else
        {
            $sql = "SELECT MAX(right_id) AS right_id
                FROM $sql_table
                $sql_where";
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);

            $item_data['left_id'] = $row['right_id'] + 1;
            $item_data['right_id'] = $row['right_id'] + 2;
        }
    
        $sql = "UPDATE $sql_table
            SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']}
            WHERE $sql_id = " . $item_data[$sql_id];
        $db->sql_query($sql);
    }
    $db->sql_freeresult($f_result);
}

?>
This is the script I need to call fixtree.php ?

User avatar
jimdunn
Registered User
Posts: 1570
Joined: Tue Mar 25, 2008 11:49 am
Location: Australia

Re: Error

Post by jimdunn » Thu Jul 10, 2008 11:48 am

Yes - if you copied that from the linked post.

(I haven't checked it's all there in what you posted :) )

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:49 am

Done.

Aishah
Registered User
Posts: 423
Joined: Fri Aug 25, 2006 7:52 am

Re: Error

Post by Aishah » Thu Jul 10, 2008 11:49 am

Thank you. I deleted the fixtree file. Have a nice day.

Locked

Return to “[3.0.x] Support Forum”