portal_name

Тема в разделе "PHP и базы данных", создана пользователем xvoid, 11 ноя 2006.

  1. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    Здравствуйте, ставил себе мод AdminPortal для phpBB, там скрипт создает все что нужно в MySQL автоматически, и он выдает ошибку...
    Я много ковырял, пришол к причине ошибки - неверное имя таблицы, делал запрос через phpMyAdmin:
    Код:
    CREATE TABLE `phpbb_portal` (
    `portal_name ` VARCHAR(255) NOT NULL ,
    `portal_value ` TEXT  NOT NULL ,
    PRIMARY KEY ( `portal_name ` ) 
    );
    Пишет:
    Код:
    Ответ MySQL:  
    #1166 - Incorrect column name 'portal_name ' 
    Я понимаю что тут идет обсуждение интерпритатора PHP, но вы ребята единственные гуру, которые знаете и любите свое дело, поэтому очень рассчитываю на вас !
    Скажите, как имя столбца может быть неверным, оно же никак независит от остальных таблиц, пиши какое хочешь имя :?

    В чем моожет быть проблема ?

    ЗЫ у меня вот какой сервер:
    Apache 2.0.54
    MySQL 4.1.12a
    PHP 5.0.4
    phpMyAdmin - 2.9.1-rc1
    MyODBC-3.51.11-2
     
  2. simpson

    simpson Активный пользователь

    С нами с:
    11 фев 2006
    Сообщения:
    1.650
    Симпатии:
    0
    Адрес:
    Санкт-Петербург
    пробел убери.
     
  3. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    simpson спасибо, после такова мне стыдно на улицу выходить :)
    А можно ещё по БД ? :)
    Вот скрипт, он обшибкуу выдает тоже при выполнении, в чем может быть фишка ?
    (зарание прошу прощения если код большой, но может так будет лучше)


    Код:
    <?php
    /***************************************************************************
     *                                install_cms.php
     *                            -------------------
     *   begin                : Saturday, Feb 13, 2001
     *   copyright            : (C) 2003 IK
     *   email                : cms@kohl-net.de
     *
     *
     ***************************************************************************/
    
    /***************************************************************************
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     *   (at your option) any later version.
     *
     ***************************************************************************/
    
    define('IN_PHPBB', true);
    $phpbb_root_path = './';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);
    
    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_INDEX);
    init_userprefs($userdata);
    //
    // End session management
    //
    
    // Check if install_cms.php has been run before
    
    $sql = "SELECT cat_type FROM " . CATEGORIES_TABLE . " ORDER BY cat_order DESC";
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    if ($row['cat_type'] == 2)
    {
    	message_die('', 'Looks like you already installed the phpBB_CMS changes :)', '', '', '', '');
    }
    
    else
    {
    // Alter the categories table
    $sql = "ALTER TABLE  " . CATEGORIES_TABLE . " ADD cat_type TINYINT NOT NULL";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not edit ' . CATEGORIES_TABLE . ' for cat_type', '', __LINE__, __FILE__, $sql);
    }
    
    // Insert the portals category
    $sql = "SELECT cat_order FROM " . CATEGORIES_TABLE . " ORDER BY cat_order DESC";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not querry the lowest category', '', __LINE__, __FILE__, $sql);
    }
    $row = $db->sql_fetchrow($result);
    $lowest_cat = $row['cat_order'] + 20;
    $sql = "SELECT cat_id FROM " . CATEGORIES_TABLE . " ORDER BY cat_id DESC";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not querry the cat_id', '', __LINE__, __FILE__, $sql);
    }
    $row = $db->sql_fetchrow($result);
    $highest_id = $row['cat_id'] + 1;
    
    $cat_name = "Portals";
    
    $sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_id, cat_title, cat_order, cat_type) VALUES ($highest_id, '$cat_name', $lowest_cat, 2)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not write portal category', '', __LINE__, __FILE__, $sql);
    }
    
    // Alter the posts table
    $sql = "ALTER TABLE  " . POSTS_TABLE . " ADD portal_post_type TINYINT NOT NULL";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not edit ' . POSTS_TABLE . ' for portal_post_type', '', __LINE__, __FILE__, $sql);
    }
    
    
    // Create CMS table & write default values
    
    $sql =	"CREATE TABLE " . $table_prefix. "cms (
    		config_id tinyint(4) NOT NULL default '0',
    		left_column smallint(4) NOT NULL default '0',
    		right_column smallint(4) NOT NULL default '0', 
    		sitemap_cats tinyint(4) NOT NULL default '0', 
    		portal_posts tinyint(4) NOT NULL default '0',
    		PRIMARY KEY  (config_id)
    		) TYPE=MyISAM";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not create table ' . $table_prefix . 'cms', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms VALUES (1, 150, 200, 3, 10)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could write default values for table ' . $table_prefix . 'cms', '', __LINE__, __FILE__, $sql);
    }
    
    
    // Create CMS Blocks table
    
    $sql =	"CREATE TABLE " . $table_prefix. "cms_blocks (
    		block_id tinyint(4) NOT NULL auto_increment,
    		name tinytext NOT NULL,
    		file tinytext NOT NULL,
    		location tinyint(4) NOT NULL default '0',
    		block_order tinyint(4) NOT NULL default '0',
    		PRIMARY KEY  (block_id)
    		) TYPE=MyISAM";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not create table ' . $table_prefix . 'cms_blocks', '', __LINE__, __FILE__, $sql);
    }
    
    // Insert blocks
    
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (1, 'Latest Content', 'block_last_content.php', 0, 30)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert Last Content Block', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (2, 'Affiliates Block', 'block_affiliates.php', 0, 20)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert Affiliates Block', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (3, 'Counter Block', 'block_counter.php', 0, 10)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert Counter Block', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (4, 'Users last on', 'block_laston.php', 1, 30)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert Last On Block', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (5, 'Last Posts', 'block_last_posts.php', 1, 40)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert Last Posts Block', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (6, 'User Control Panel', 'block_user_cp.php', 1, 20)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert User CP Block', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "cms_blocks VALUES (7, 'Site search block', 'block_site_search.php', 1, 50)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert Site Search Block', '', __LINE__, __FILE__, $sql);
    }
    
    // Table and content for counter block
    
    $sql =	"CREATE TABLE " . $table_prefix. "counter (id tinyint(4) NOT NULL default '0', count int(11) NOT NULL default '0', PRIMARY KEY  (id)) TYPE=MyISAM";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not create counter block table', '', __LINE__, __FILE__, $sql);
    }
    
    $sql =	"INSERT INTO " . $table_prefix. "counter VALUES (1, 1)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert counter value', '', __LINE__, __FILE__, $sql);
    }
    
    
    // Insert first CMS category, forums, topics and posts
    
    $lowest_cat -= 10;
    $sql =	"INSERT INTO " . $table_prefix. "categories VALUES (3, 'Home', $lowest_cat, 1)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first CMS category', '', __LINE__, __FILE__, $sql);
    }
    
    $sql =	"INSERT INTO " . $table_prefix. "forums VALUES (2, 3, 'Test', '', 0, 10, 1, 1, 2, NULL, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first content forum', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "forums VALUES (3, 2, 'Home', '', 0, 10, 2, 1, 4, NULL, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first portal forum', '', __LINE__, __FILE__, $sql);
    }
    
    $sql =	"INSERT INTO " . $table_prefix. "topics VALUES (2, 2, 'First Topic', 2, 1047745804, 3, 0, 0, 0, 0, 2, 2, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first content topic', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "topics VALUES (3, 3, 'First news item', 2, 1047745843, 5, 1, 0, 0, 0, 3, 5, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first portal topic', '', __LINE__, __FILE__, $sql);
    }
    
    $sql =	"INSERT INTO " . $table_prefix. "posts VALUES (2, 2, 2, 2, 1047745804, '7f000001', '', 1, 0, 1, 0, NULL, 0, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert content post', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "posts VALUES (3, 3, 3, 2, 1047745843, '7f000001', '', 1, 0, 1, 0, NULL, 0, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first portal post', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "posts VALUES (5, 3, 3, 2, 1048411991, '7f000001', '', 1, 0, 1, 0, NULL, 0, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert second portal post', '', __LINE__, __FILE__, $sql);
    }
    
    $sql =	"INSERT INTO " . $table_prefix. "posts_text VALUES (2, '614a0bab2d', 'First Topic', 'Hi, this is the first content page of the [b]First Topic [/b]menu point ! Congratulations !!! :P')";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert content post text', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "posts_text VALUES (3, 'b623251ecb', 'First news item', 'Hello, this is the first news item for your page')";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first portal post text', '', __LINE__, __FILE__, $sql);
    }
    $sql =	"INSERT INTO " . $table_prefix. "posts_text VALUES (5, '5472e72826', 'Second news item', 'This is the second news item')";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert second portal post text', '', __LINE__, __FILE__, $sql);
    }
    
    
    
    message_die('', 'Congratulations, you have successfully installed the phpBB_CMS changes to your database', '', '', '', '');
    
    }
    
    ?>
     
  4. simpson

    simpson Активный пользователь

    С нами с:
    11 фев 2006
    Сообщения:
    1.650
    Симпатии:
    0
    Адрес:
    Санкт-Петербург
    xvoid, ошибку хоть покажи.
     
  5. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    Кскюзми :)
    Код:
    Could not insert first content forum
    
    DEBUG MODE
    
    SQL Error : 1136 Column count doesn't match value count at row 1
    
    INSERT INTO phpbb_forums VALUES (2, 3, 'Test', '', 0, 10, 1, 1, 2, NULL, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0)
    
    Line : 187
    File : install_cms.php
     
  6. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    Строка 187 и весь запрос:
    Код:
    $sql =	"INSERT INTO " . $table_prefix. "forums VALUES (2, 3, 'Test', '', 0, 10, 1, 1, 2, NULL, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0)";
    if( !($result = $db->sql_query($sql)) )
    {
    	message_die(GENERAL_ERROR, 'Could not insert first content forum', '', __LINE__, __FILE__, $sql);
    }
     
  7. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    В чем трабл ?
     
  8. simpson

    simpson Активный пользователь

    С нами с:
    11 фев 2006
    Сообщения:
    1.650
    Симпатии:
    0
    Адрес:
    Санкт-Петербург
    переведи сообщение об ошибке
     
  9. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    Нехватает ему чета, а че нехватает непойму
    Column count doesn't match value count at row 1

    VALUES (2, 3, - типа 2 - это первая строка, а че её нехватает ?
     
  10. simpson

    simpson Активный пользователь

    С нами с:
    11 фев 2006
    Сообщения:
    1.650
    Симпатии:
    0
    Адрес:
    Санкт-Петербург
     
  11. xvoid

    xvoid Активный пользователь

    С нами с:
    10 авг 2006
    Сообщения:
    152
    Симпатии:
    0
    Действительно разные были, мод аттачмента чтоит, он добавляет значение своей переменной везде, переписал дамп, заработало.

    Вот ещё один вопрос, я дам делал майадмином, сдампил в кривой кодировке, решил не настраивать а сдампить с помощью скрипта Sypex Dumper Lite 1.0.8
    Короче удалил все из БД, восстановил им старый дамп, и добавил одну таблицу (выше писал, где пробел убрать забыли), вобщем начал дампить уже с новой таблицей, в скрипте выдает ошибку

    Возникла ошибка!
    Undefined index: phpbb_portal (8)

    Непойму какой неопределенный индекс, таблица как все, чем она так отличается, что ошибку мне сует дампер ?