[SOLVED] [XASECO1] MySql connection syntax

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

[SOLVED] [XASECO1] MySql connection syntax

Post by Adgenodux » 04 Dec 2016 21:02

Hi all,

I'm trying to configure Xaseco1 for TMNF under Ubuntu 16.04 LTS - PHP 7.

Unfortunately, i had a 1st problem with mysql_connect into

Code: Select all

../xaseco/plugins/plugin.localdatabase.php
I have changed all mysql_ with mysqli_ however now i have this error :

Code: Select all

[PHP Warning] mysqli_select_db() expects exactly 2 parameters, 1 given on line 77 in file ../xaseco/plugins/plugin.localdatabase.php
So, what's the correct syntax of this ?

Code: Select all

if (!mysqli_select_db($ldb_settings['mysql']['database'])) {
                trigger_error('[LocalDB] Could not find MySQL database!', E_USER_ERROR);
        }
... or, is there a more recent version to be used under php7 ?

... or, another controller ?

Thanks for tips...
Last edited by Adgenodux on 22 Dec 2016 19:21, edited 1 time in total.

Xymph
Pit Crew
Pit Crew
Posts: 5648
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: [XASECO1] MySql connection syntax

Post by Xymph » 05 Dec 2016 08:39

Adgenodux wrote:... or, is there a more recent version to be used under php7 ?
No.
Adgenodux wrote: ... or, another controller ?
Controllers aplenty but most if not all using MySQL will have the same problem on PHP7.
Adgenodux wrote: Thanks for tips...
Port this to X1.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [XASECO1] MySql connection syntax

Post by Adgenodux » 05 Dec 2016 17:32

Hi Xymph and thanks for your reply...

Thanks for the nice tip Modernizer, looks like it works natively with X1, however i've got some errors, even if it seems working partially (i've got the Xaseco and dedimania start messages into TM and the extra console commands however no widget displayed and some errors in logfile, supposed related to Modernizer)

But i've got a question for you...

How can i see in my OS console if Xaseco is running as i can't see nothing about into htop ? Previously, Manialive was into the processes list and as i've launched Xaseco many times during tests, can it be launched multiple times for same server and how to see it into proccesses ?

Thanks for infos...

Xymph
Pit Crew
Pit Crew
Posts: 5648
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: [XASECO1] MySql connection syntax

Post by Xymph » 05 Dec 2016 20:18

Adgenodux wrote:How can i see in my OS console if Xaseco is running as i can't see nothing about into htop ?

Code: Select all

ps ax | grep php
Adgenodux wrote:Previously, Manialive was into the processes list and as i've launched Xaseco many times during tests, can it be launched multiple times for same server and how to see it into proccesses ?
Don't know, that sentence doesn't parse in English. ;)
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [XASECO1] MySql connection syntax

Post by Adgenodux » 05 Dec 2016 21:09

this

Code: Select all

ps ax | grep php
... will answer to my questions...

thx :mrgreen:

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [XASECO1] MySql connection syntax

Post by Adgenodux » 14 Dec 2016 13:34

well,

Now with Modernizer, the functions are working correctly but it looks like i have a small sql query issue.

So after initialization, i've got this :

Code: Select all

###############################################################################
  XASECO v1.16 running on 127.0.0.1:5010
  Name   : Test Server - My_TM_server
  Game   : TmForever United - Stadium - TimeAttack
  Version: 2.11.26 / 2011-02-21
  Authors: Florian Schnell & Assembler Maniac
  Re-Authored: Xymph
###############################################################################
Begin Challenge
[XASECO Warning] Could not get challenge info! (Unknown column 'r.ChallengeId' in 'on clause')
sql = SELECT c.Id AS ChallengeId, r.Score, p.NickName, p.Login, r.Date, r.Checkpoints
                  FROM challenges c
                  LEFT JOIN records r ON (r.ChallengeId=c.Id)
                  LEFT JOIN players p ON (r.PlayerId=p.Id)
                  WHERE c.Uid='xx_xxxxxxxxxxxxxxxxxxxxxxxxxx'
                  GROUP BY r.Id
                  ORDER BY r.Score ASC,r.Date ASC
                  LIMIT 50
[12/14,14:12:24] track changed [undefined] >> [MY_TM_server]
[12/14,14:12:24] currently no record on MY_TM_server
Into db, i only have one entry into challenges table, no rows into other tables...

So, could it be because there are no records yet and it will solve hitself after some recorded datas or is it a query syntax error ?

Thanks for help...

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [XASECO1] MySql connection syntax

Post by Adgenodux » 22 Dec 2016 16:09

Well,

After a search time and comments into the developpez.net mysql section, the problem could be related to missing colums to make jonctions between tables...

Below is the plugin.localdatabase.php main tables creation process so could someone tell me how adding missing parts ?

Code: Select all

// create main tables
        $query = "CREATE TABLE IF NOT EXISTS `challenges` (
                    `Id` mediumint(9) NOT NULL auto_increment,
                    `Uid` varchar(27) NOT NULL default '',
                    `Name` varchar(100) NOT NULL default '',
                    `Author` varchar(30) NOT NULL default '',
                    `Environment` varchar(10) NOT NULL default '',
                    PRIMARY KEY (`Id`),
                    UNIQUE KEY `Uid` (`Uid`)
                  ) ENGINE=MyISAM";
        mysql_query($query);
 
        $query = "CREATE TABLE IF NOT EXISTS `players` (
                    `Id` mediumint(9) NOT NULL auto_increment,
                    `Login` varchar(50) NOT NULL default '',
                    `Game` varchar(3) NOT NULL default '',
                    `NickName` varchar(100) NOT NULL default '',
                    `Nation` varchar(3) NOT NULL default '',
                    `UpdatedAt` datetime NOT NULL default '0000-00-00 00:00:00',
                    `Wins` mediumint(9) NOT NULL default 0,
                    `TimePlayed` int(10) unsigned NOT NULL default 0,
                    `TeamName` char(60) NOT NULL default '',
                    PRIMARY KEY (`Id`),
                    UNIQUE KEY `Login` (`Login`),
                    KEY `Game` (`Game`)
                  ) ENGINE=MyISAM";
        mysql_query($query);
 
        $query = "CREATE TABLE IF NOT EXISTS `records` (
                    `Id` int(11) NOT NULL auto_increment,
                    `ChallengeId` mediumint(9) NOT NULL default 0,
                    `PlayerId` mediumint(9) NOT NULL default 0,
                    `Score` int(11) NOT NULL default 0,
                    `Date` datetime NOT NULL default '0000-00-00 00:00:00',
                    `Checkpoints` text NOT NULL,
                    PRIMARY KEY (`Id`),
                    UNIQUE KEY `PlayerId` (`PlayerId`,`ChallengeId`),
                    KEY `ChallengeId` (`ChallengeId`)
                  ) ENGINE=MyISAM";
        mysql_query($query);
 
        $query = "CREATE TABLE IF NOT EXISTS `players_extra` (
                    `playerID` mediumint(9) NOT NULL default 0,
                    `cps` smallint(3) NOT NULL default -1,
                    `dedicps` smallint(3) NOT NULL default -1,
                    `donations` mediumint(9) NOT NULL default 0,
                    `style` varchar(20) NOT NULL default '',
                    `panels` varchar(255) NOT NULL default '',
                    PRIMARY KEY (`playerID`),
                    KEY `donations` (`donations`)
                  ) ENGINE=MyISAM";
        mysql_query($query);
Thanks for help...

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [XASECO1] MySql connection syntax

Post by Adgenodux » 22 Dec 2016 19:20

well,

finaly solved with the help of developpez.net community...

was a db corruption (missing some columns, invalid default date format and missing Id auto-increment) so erased than manualy rebuilt one by one throw phpmyadmin challenges, players, records and rs_x tables using sql files provided with Xaseco, modified the date and datetime default values to "1000-01-01 00:00:00" and now it runs...

Xymph
Pit Crew
Pit Crew
Posts: 5648
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: [SOLVED] [XASECO1] MySql connection syntax

Post by Xymph » 23 Dec 2016 08:50

Glad to hear it wasn't something in the code. :thumbsup:
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [SOLVED] [XASECO1] MySql connection syntax

Post by Adgenodux » 23 Dec 2016 10:19

sure... :mrgreen:

however, maybe you could just warn somewhere that from mysql version 5.7, strict mode affects whether the server permits '0000-00-00' as a valid date...

so default date/datetime format could needs to be changed to "1000-01-01 00:00:00" or STRICT_TRANS_TABLES mode disabled (see http://stackoverflow.com/questions/3637 ... r-datetime) to avoid problems...

btw, very nice tool Xaseco, gj man :thumbsup:

unfortunately, many third-parties plugins appear outdated...

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [SOLVED] [XASECO1] MySql connection syntax

Post by Adgenodux » 23 Dec 2016 16:10

Into the developpez.net thread, someone is talking about the REFERENCE CONSTRAINT type to avoid, i.e, to insert ChallengeId or PlayerID into RECORDS without link into CHALLENGE or PLAYER, or keeping id's that not exist into tables anymore... question of db integrity...

He has posted this:

Code: Select all

CREATE TABLE IF NOT EXISTS 
       `records` (`Id`          int(11)      NOT NULL auto_increment,
                  `ChallengeId` mediumint(9) NOT NULL default 0,
                  `PlayerId`    mediumint(9) NOT NULL default 0,
                  `Score`       int(11)      NOT NULL default 0,
                  `Date`        datetime     NOT NULL default '0000-00-00 00:00:00',
                  `Checkpoints` text         NOT NULL,
                  PRIMARY KEY (`Id`),  
                  UNIQUE  KEY `PlayerId` (`PlayerId`,`ChallengeId`),
                  KEY         `ChallengeId` (`ChallengeId`)
                  CONSTRAINT `fk1_challengid` 
                              FOREIGN KEY (`ChallengeId`)
                              REFERENCES   `Challenge` (`id`)
                              ON UPDATE CASCADE
                              ON DELETE CASCADE
                  CONSTRAINT `fk2_playerid` 
                              FOREIGN KEY (`PlayerId`)
                              REFERENCES   `Players` (`id`)
                              ON UPDATE CASCADE
                              ON DELETE CASCADE
                 )
what do you think about ?

should it be fixed ?

Xymph
Pit Crew
Pit Crew
Posts: 5648
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: [SOLVED] [XASECO1] MySql connection syntax

Post by Xymph » 23 Dec 2016 21:19

Adgenodux wrote:what do you think about ?
should it be fixed ?
No idea, I ceased actively developing XAseco long ago, and am not familiar with those MySQL features / problems.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Adgenodux
pedestrian
pedestrian
Posts: 14
Joined: 04 Dec 2016 20:52
Owned TM-games: TMN TMU

Re: [SOLVED] [XASECO1] MySql connection syntax

Post by Adgenodux » 24 Dec 2016 00:50

damn...

thanks anyway... :-?

Post Reply