Advertisement:

Author Topic: Mods can't create tables in MYSQL database  (Read 24365 times)

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Mods can't create tables in MYSQL database
« on: April 26, 2008, 08:07:38 PM »
Every mod that requires a table in the database doesn't work simply because the mods can't create the tables in the database for some reason.

For example, if I install the bookmarks mod I get this:
Quote
Table 'Trackmania.smf1_bookmarks' doesn't exist
File: /mounted-storage/home30c/sub002/sc26341-IINL/www/FlemishArmySite/Trackmania/Sources/Bookmarks.php
Line: 115

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,849
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Mods can't create tables in MYSQL database
« Reply #1 on: April 26, 2008, 09:26:21 PM »
Are there any errors in your forum error log related to table creation?
Michael Eshom
Cincy Space - now open!

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #2 on: April 27, 2008, 03:41:05 AM »
I have 5 database errors and they are all "doesn't exist" errors. No creation or connection errors.

The forum installation went fine, and every mod I install works fine, as long as it doesn't require a new table.

I get these "doesn't exist" errors on every page that requires the table.

I am using default theme and default language so It can't be any more compatible then that.
« Last Edit: April 27, 2008, 03:50:06 AM by Jelle Mees »

Offline SwapsRulez

  • Jr. Member
  • **
  • Posts: 208
  • Gender: Male
  • Its better to burn out than to fade away...!!!
    • Project-BB
Re: Mods can't create tables in MYSQL database
« Reply #3 on: April 27, 2008, 06:29:06 AM »
I have 5 database errors and they are all "doesn't exist" errors. No creation or connection errors.

The forum installation went fine, and every mod I install works fine, as long as it doesn't require a new table.

I get these "doesn't exist" errors on every page that requires the table.

I am using default theme and default language so It can't be any more compatible then that.

I think try installing the MODS in the manual way & check out for the changes in the file. After completing the files editing part. Just go to phpmyadmin, there in your database. run the query given in the instructions of the MOD. You'll find it working in that way ;)
Project-BB.org : Educational Forum For Engineering, Diploma & Technical Students

The Engineering, Diploma & All technical students lounge for Free Projects, Seminars, Syllabus, Question Papers, College Assignments, Placement Papers, E-Books, Company Information & other technical stuffs.

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Mods can't create tables in MYSQL database
« Reply #4 on: April 27, 2008, 08:16:11 AM »
Does the SMF MySQL user have permissions to create new tables? You can check in cpanel or whichever control panel you have
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #5 on: April 28, 2008, 01:00:31 PM »
@SwapsRules:
There is no query givin, almost nobody does that. What I do have is this:

Code: [Select]
<?php
global $smcFunc;

$smcFunc['db_create_table']('bookmarks',
array(
array(
'name' => 'id_member',
'type' => 'mediumint',
'size' => 8,
),
array(
'name' => 'id_topic',
'type' => 'mediumint',
'size' => 8,
),
),
array(
'name' => 'bookmark',
'type' => 'unique',
'columns' => array('id_member''id_topic'),
),
array(),
'ignore');
?>

My SQL knowledge is to low for me to rewrite as a SQL command.

@H:
Eeuhm, I don't know what you are talking about. I created mysql table and installed SMF, what are these permissions you talk about???

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Mods can't create tables in MYSQL database
« Reply #6 on: April 28, 2008, 01:02:40 PM »
The bookmarks mod didn't fully install which is why you're getting these errors. Most likely the SMF user may not have permissions to create tables?
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #7 on: April 28, 2008, 01:05:55 PM »
The bookmarks mod didn't fully install which is why you're getting these errors. Most likely the SMF user may not have permissions to create tables?

I am the SMF user, the admin. There is only one account on my SMF forum and that's the admin account.

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: Mods can't create tables in MYSQL database
« Reply #8 on: April 28, 2008, 01:18:54 PM »
H meant MySQL User admin, not SMF permissions, MySQL users got there separate permissions for various things like creating, altering tables etc etc.

They should be in host control panel.

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #9 on: April 29, 2008, 11:50:20 AM »
H meant MySQL User admin, not SMF permissions, MySQL users got there separate permissions for various things like creating, altering tables etc etc.

They should be in host control panel.

Again, don't really understand what you are talking about. I am admin and have FULL rights to everything. SMF, MYSQL, PHP settings, etc...
I can go to phpmyamin and create tables.

And I don't understand why you ask this.

Installing SMF = creating tables in MYSQL database, without that permission you can't eaven install SMF, or am I mistaking...

---------------------------------------------------

Maybe this is the problem.

Look at the code:

Code: [Select]
<?php
global $smcFunc;

$smcFunc['db_create_table']('bookmarks',

I see "Global", does that mean that I need to enable global variables in order for the installation to succeed?
« Last Edit: April 29, 2008, 11:51:59 AM by Jelle Mees »

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Mods can't create tables in MYSQL database
« Reply #10 on: April 29, 2008, 03:31:50 PM »
global variables cannot be disabled (if they could then none of SMF would be working!).

Which bookmark mod are you using? You did install through the Package Manager?
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #11 on: April 29, 2008, 04:42:19 PM »
global variables cannot be disabled (if they could then none of SMF would be working!).

Which bookmark mod are you using? You did install through the Package Manager?

It doesn't mather wich mod it is, every single mod that requires new MYSQL tables does not work, simply because the tables are not getting created.

And yes, I use the package manager for all my mods.

PS: Thanks for not giving up on me :)

Offline rsw686

  • Sophist Member
  • *****
  • Posts: 1,008
    • The Reptile File
Re: Mods can't create tables in MYSQL database
« Reply #12 on: April 29, 2008, 08:57:16 PM »
Check the mysql user permissions. Are you sure they didn't get changed after you installed SMF. Thats the only thing I can think of.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #13 on: April 30, 2008, 11:36:24 AM »
Check the mysql user permissions. Are you sure they didn't get changed after you installed SMF. Thats the only thing I can think of.

I am admin, 100000000% sure.

Have you guys installed mods that require new MYSQL tables? I don't mind that you assume that I am doing something rong, but have you guys actually tried it yourself?

Offline rsw686

  • Sophist Member
  • *****
  • Posts: 1,008
    • The Reptile File
Re: Mods can't create tables in MYSQL database
« Reply #14 on: April 30, 2008, 11:43:47 AM »
Have you guys installed mods that require new MYSQL tables? I don't mind that you assume that I am doing something rong, but have you guys actually tried it yourself?

I have, I just use a create table sql statement with the query function. If I have some time later I'll test out the create table function.
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #15 on: April 30, 2008, 11:47:29 AM »
Just know that I don't have this problem with phpbb.

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,629
  • Gender: Male
    • Criminal Brief UK
Re: Mods can't create tables in MYSQL database
« Reply #16 on: April 30, 2008, 11:48:27 AM »
Its unlikely that using create table will work for postgresql or sqlite.
At the moment very few mods that work for 2.x have needed to create a table.

This probably isn't stylised as much as I'd like. But I'm successfully using
Quote
// Columns for our table
$table_columns = array(
   array('name' => 'id_member', 'type' => 'mediumint', 'size' => 8, 'null' => false, 'default' => 0),
   array('name' => 'id_topic', 'type' => 'mediumint', 'size' => 8, 'null' => false, 'default' => 0),
   array('name' => 'date_ignored', 'type' => 'int', 'size' => 10, 'null' => false, 'default' => 0)
);

// Indexes for our table
$table_indexes = array(
   array('name' => 'topic', 'columns' => array('id_member', 'id_topic'), 'type' => 'unique')
);

// Create the table
$smcFunc['db_create_table']('ignore_topics', $table_columns, $table_indexes);
On one of my unreleased mods.

Offline Jelle Mees

  • Jr. Member
  • **
  • Posts: 140
Re: Mods can't create tables in MYSQL database
« Reply #17 on: April 30, 2008, 11:52:13 AM »
Can I trust someone with admin acces on my forum? Maybe if I give one of you guys admin acces on my forum + MYSQL connection data, you might be able to see what's happening.

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,662
  • Gender: Male
Re: Mods can't create tables in MYSQL database
« Reply #18 on: April 30, 2008, 01:24:33 PM »
A reminder about admin / ftp passwords...

Generally anyone with a staff 'badge' or someone with the "<Insert team> Team Apprentice". Karl seems to have a few ideas up his sleeve :)
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

Offline rsw686

  • Sophist Member
  • *****
  • Posts: 1,008
    • The Reptile File
Re: Mods can't create tables in MYSQL database
« Reply #19 on: April 30, 2008, 01:35:17 PM »
Okay this is slightly strange. I put together a short script using Karl's code and including the SSI file. The db_create_table is not a valid index in the array. I did a var_dump of smcFunc and it is not there. The other functions like db_query work as expected. Has anybody gotten this to work with SSI. I guess I could stick this in an SMF page somewhere to test. I just know that some people prefer to run the scripts separate from the package manager.

Code: [Select]
<?php
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
include_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

// This works fine
$request $smcFunc['db_query']('''
SELECT ID_PROFILE FROM {db_prefix}profile'
);
$rows $smcFunc['db_num_rows']($request);
$smcFunc['db_free_result']($request);

// Columns for our table
$table_columns = array(
   array(
'name' => 'id_member''type' => 'mediumint''size' => 8'null' => false'default' => 0),
   array(
'name' => 'id_topic''type' => 'mediumint''size' => 8'null' => false'default' => 0),
   array(
'name' => 'date_ignored''type' => 'int''size' => 10'null' => false'default' => 0)
);

// Indexes for our table
$table_indexes = array(
   array(
'name' => 'topic''columns' => array('id_member''id_topic'), 'type' => 'unique')
);

// Look at the var dump
var_dump($smcFunc);

// This doesn't work
// Create the table
$smcFunc['db_create_table']('ignore_topics'$table_columns$table_indexes);
?>

The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts