Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: smithy on April 24, 2007, 12:36:22 PM

Title: Database Problem
Post by: smithy on April 24, 2007, 12:36:22 PM
Hello,
I have just installed another smf forum. My 3rd infact. Anyway Rather that just install the forum, get members to it then start playing around with it. I decided i want to do all the changers first before getting users to it. Now i got my nice new forum and a nice theme. Added nice buttons and stuff and its starting to look good.

I tried to install the Ad Mod but my server wont let it. Server paths are correct so something is blocking me from installing mods on the forum.

I then search the forum for a manual install of mods which i found. Great i thought! Altered all the files with the ad before, after and replace. Piece of cake untill a realised i still had to install the database for that particular mod. I then checked the install.php for the database tables but it didnt look like any sql.txt file i have seen before but i thought i would give it a shot. Nope not in a million years will i get the tables installed. There must be something i should do or alter to get this thing working?

The install.php looks like this

<?php

/*
Installing the ad mod for the first time
*/
db_query("
CREATE TABLE IF NOT EXISTS
{$db_prefix}ads (
ADS_ID mediumint(8) unsigned NOT NULL auto_increment,
NAME tinytext NOT NULL,
CONTENT text NOT NULL,
BOARDS tinytext,
POSTS tinytext,
HITS mediumint(8) NOT NULL default '0',
TYPE smallint(4) NOT NULL default '0',
show_index smallint(4) NOT NULL default '0',
show_board smallint(4) NOT NULL default '0',
show_threadindex smallint(4) NOT NULL default '0',
show_lastpost smallint(4) NOT NULL default '0',
show_thread smallint(4) NOT NULL default '0',
show_bottom smallint(4) NOT NULL default '0',
show_welcome smallint(4) NOT NULL default '0',
show_topofpage smallint(4) NOT NULL default '0',
show_towerright smallint(4) NOT NULL default '0',
show_towerleft smallint(4) NOT NULL default '0',
show_betweencategories smallint(4) NOT NULL default '0',
show_underchildren smallint(4) NOT NULL default '0',
PRIMARY KEY (ADS_ID)
)"
, __FILE__, __LINE__);

db_query("
CREATE TABLE IF NOT EXISTS
{$db_prefix}ads_settings (
&#160; variable tinytext NOT NULL,
&#160; value text NOT NULL,
&#160; PRIMARY KEY (variable(30))
)"
, __FILE__, __LINE__);

/*
If you've already had the mod installed this will just make sure that you have the most current version of the database
*/
$result = db_query("SHOW COLUMNS FROM {$db_prefix}ads LIKE 'show_lastpost'", __FILE__, __LINE__);
if (
mysql_num_rows($result) == 0)
db_query("
ALTER IGNORE TABLE
{$db_prefix}ads
ADD show_lastpost smallint(4) NOT NULL default '0' AFTER show_threadindex"
, __FILE__, __LINE__);

$result = db_query("SHOW COLUMNS FROM {$db_prefix}ads LIKE 'CATEGORY'", __FILE__, __LINE__);
if (
mysql_num_rows($result) == 0)
db_query("
ALTER IGNORE TABLE
{$db_prefix}ads
ADD CATEGORY tinytext AFTER POSTS"
, __FILE__, __LINE__);

$result = db_query("SHOW COLUMNS FROM {$db_prefix}ads LIKE 'show_underchildren'", __FILE__, __LINE__);
if (
mysql_num_rows($result) == 0)
db_query("
ALTER IGNORE TABLE
{$db_prefix}ads
ADD show_underchildren smallint(4) NOT NULL default '0'"
, __FILE__, __LINE__);


/*
Inserts into the settings table
*/
db_query("
INSERT IGNORE INTO
{$db_prefix}settings
(variable, value)
VALUES ('ads_displayAdsAdmin', '0'),
('ads_updateReports', '0'),
('ads_quickDisable', '0'),
('ads_lookLikePosts', '1')"
, __FILE__, __LINE__);
?>


I guess its the first 2 tables i have to install but i keep getting mysql said syntex errors.

Can somebody kindly tell me what i must do to get the tables installed.

Thanks
smithy

Title: Re: Database Problem
Post by: Kindred on April 24, 2007, 12:56:13 PM
1- please use the code tags...

2- that is a PHP file designed to run SQL commands, using the SMF SQL parser function.


If you want to run those manually, you will have to replace {$db_prefix} with your database prefix and copy thr section inside the db_query quotes...

Alternatively, you can upload the php file and run it by browsing directly to it...
Title: Re: Database Problem
Post by: smithy on April 24, 2007, 01:23:37 PM
Thanks for the reply.
I did lauch the install.php file but i get this error.

Fatal error: Call to undefined function: db_query() in /home/user/domains/mydomain.com/public_html/Packages/ad_mod_1-1-x_v2-3/install.php on line 6

Sorry, i dont realy understand what you mean by this.

If you want to run those manually, you will have to replace {$db_prefix} with your database prefix and copy thr section inside the db_query quotes.

Cheers
smithy

Title: Re: Database Problem
Post by: Kindred on April 24, 2007, 01:43:08 PM
for example:


CREATE TABLE IF NOT EXISTS smf_ads (
ADS_ID mediumint(8) unsigned NOT NULL auto_increment,
NAME tinytext NOT NULL,
CONTENT text NOT NULL,
BOARDS tinytext,
POSTS tinytext,
HITS mediumint(8) NOT NULL default '0',
TYPE smallint(4) NOT NULL default '0',
show_index smallint(4) NOT NULL default '0',
show_board smallint(4) NOT NULL default '0',
show_threadindex smallint(4) NOT NULL default '0',
show_lastpost smallint(4) NOT NULL default '0',
show_thread smallint(4) NOT NULL default '0',
show_bottom smallint(4) NOT NULL default '0',
show_welcome smallint(4) NOT NULL default '0',
show_topofpage smallint(4) NOT NULL default '0',
show_towerright smallint(4) NOT NULL default '0',
show_towerleft smallint(4) NOT NULL default '0',
show_betweencategories smallint(4) NOT NULL default '0',
show_underchildren smallint(4) NOT NULL default '0',
PRIMARY KEY (ADS_ID)
);
Title: Re: Database Problem
Post by: smithy on April 24, 2007, 04:53:20 PM
Thank you guys. It worked :) Atleast i will know what to do next time.

Cheers
smithy