Fatal error - class.engine.php

LouisJW

Active Member
May 20, 2020
139
53
So, usually I wouldn't post stuff like this but it's annoying now and is probably something so simple.

When I go to localhost I get this error.

Fatal error: Function name must be a string in C:\inetpub\wwwroot\app\class.engine.php on line 48

Line 48 of class.engine.php

$this->connection = $this->mysql[$type]($_CONFIG['mysql']['hostname'], $_CONFIG['mysql']['username'], $_CONFIG['mysql']['password']);

Help would be greatly appreciated; sorry in advance for annoyance.
 

LouisJW

Active Member
May 20, 2020
139
53
PHP:
<?php

namespace Revolution;
if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }
class engine
{
    private $initiated;
    private $connected;
    
    private $connection;
    
    
    final public function Initiate()
    {
        global $_CONFIG;
        if(!$this->initiated)
        {
            $this->setMySQL('connect', mysql_connect);
            $this->setMySQL('pconnect', mysql_pconnect);
            $this->setMysql('select_db', mysql_select_db);
            $this->setMySQL('query', mysql_query);
            $this->setMySQL('num_rows', mysql_num_rows);
            $this->setMySQL('fetch_assoc', mysql_fetch_assoc);
            $this->setMySQL('fetch_array',mysql_fetch_array);
            $this->setMySQL('result', mysql_result);
            $this->setMySQL('free_result', mysql_free_result);
            $this->setMySQL('escape_string', mysql_real_escape_string);
            
            $this->initiated = true;
        
            $this->connect($_CONFIG['mysqli']['connection_type']);
        }
    }
    
    final public function setMySQL($key, $value)
    {
        $this->mysql[$key] = $value;
    }
    
    
    /*-------------------------------Manage Connection-------------------------------------*/
    
    final public function connect($type)
    {
        global $core, $_CONFIG;
        if(!$this->connected)
        {
            $this->connection = $this->mysql[$type]($_CONFIG['mysql']['hostname'], $_CONFIG['mysql']['username'], $_CONFIG['mysql']['password']);
            
            if($this->connection)
            {
                $mydatabase = $this->mysql['select_db']($_CONFIG['mysql']['database'], $this->connection);
                
                if($mydatabase)
                {
                    $this->connected = true;   
                }
                else
                {
                    $core->systemError('MySQL Engine', 'MySQL could not connect to database');
                }
            }
            else
            {
                $core->systemError('MySQL Engine', 'MySQL Doesnt want to connect, bitch.');           
            }
        }
    }
    
    final public function disconnect()
    {
        global $core;
        if($this->connected)
        {
            if($this->mysql['close'])
            {
                $this->connected = false;
            }
            else
            {
                $core->systemError('MySQL Engine', 'MySQL could not disconnect.');
            }
        }
    }
    
    /*-------------------------------Secure MySQL variables-------------------------------------*/
    
    final public function secure($var)
    {
        return $this->mysql['escape_string'](stripslashes(htmlspecialchars($var)));
    }
    
    /*-------------------------------Manage MySQL queries-------------------------------------*/
    
    final public function query($sql)
    {
        return $this->mysql['query']($sql, $this->connection) or die(mysql_error());
    }
    
    final public function num_rows($sql)
    {
        return $this->mysql['num_rows']($this->mysql['query']($sql, $this->connection));
    }
    
    final public function result($sql)
    {
        return $this->mysql['result']($this->mysql['query']($sql, $this->connection), 0);
    }
    
    final public function free_result($sql)
    {
        return $this->mysql['free_result']($sql);
    }
    
    final public function fetch_array($sql)
    {
        $query = $this->mysql['query']($sql, $this->connection);
        
        $data = array();
        
        while($row = $this->mysql['fetch_array']($query))
        {
            $data[] = $row;
        }
        
        return $data;
    }
    
    final public function fetch_assoc($sql)
    {
        return $this->mysql['fetch_assoc']($this->mysql['query']($sql, $this->connection));
    }




}
?>

This is my class.engine.php file, do you see anything that doesn't look right?
 

LouisJW

Active Member
May 20, 2020
139
53
Check your config.php file.
I have done, changed
PHP:
$_CONFIG['mysql']['connection_type'] = 'pconnect'; // This MUST be either connect or pconnect (if you want a persistent connection).
from connect to pconnect; nothing changes. All is correct in config.
 

LouisJW

Active Member
May 20, 2020
139
53
Please share your config file hiding any passwords ect
PHP:
<?php

if(!defined('IN_INDEX')) { die('Sorry, you cannot access this file.'); }

/*
  ____  _           _     ____ __  __ ____ 
 / ___|| | ___  ___| | __/ ___|  \/  / ___|
 \___ \| |/ _ \/ _ \ |/ / |   | |\/| \___ \
  ___) | |  __/  __/   <| |___| |  | |___) |
 |____/|_|\___|\___|_|\_\\____|_|  |_|____/  - theme by Platinum.
                                            
#NOTE: Please carefully read and fill out the configurations below in order for your website and hotel to work.

*/

/*
*
*    MySQL Management - Be sure to fill in the bottom MySQL configuration correctly in order for your database to be connected.
*
*/

$_CONFIG['mysql']['connection_type'] = 'pconnect'; // This MUST be either connect or pconnect (if you want a persistent connection).

$_CONFIG['mysql']['hostname'] = '127.0.0.1'; // This is your MySQL host.

$_CONFIG['mysql']['username'] = 'root'; // Enter your MySQL username.

$_CONFIG['mysql']['password'] = ''; // Enter your MySQL password.

$_CONFIG['mysql']['database'] = ''; // Enter your hotel database name.

$_CONFIG['mysql']['port'] = '3306'; // This is your MySQL port.

/*
*
*    Hotel Management - Configure your details below in order to get your retro up and running!
*
*/

$_CONFIG['hotel']['server_port'] = '30000'; // This is the port that your emulator is ran off. (Default - 30000).

$_CONFIG['hotel']['url'] = 'http://localhost'; // Enter your hotel's URL with either the "www.", "http://" or "https://" at the start.

$_CONFIG['hotel']['proxy'] = ''; // Enter your hotel's proxy IP or proxy URL, otherwise put in your VPS IP (it is highly recommended that you get a proxy).

$_CONFIG['hotel']['shorturl'] = 'localhost'; // This is your hotel's URL without the "www.", "http://" or "https://".

$_CONFIG['hotel']['name'] = 'Project'; // Your hotel name will go here.

$_CONFIG['hotel']['desc'] = ''; // Modify this if you wish to use the same tab description on all your pages.

$_CONFIG['hotel']['email'] = '[email protected]'; // Modify this if you wish to leave a contact email on your website.

$_CONFIG['hotel']['in_maint'] = false; // Write "true" to make the website appear in maintenance, otherwise write "false".

$_CONFIG['hotel']['motto'] = 'I <3 ' . $_CONFIG['hotel']['name']; // This will be the default motto upon registeration.

$_CONFIG['hotel']['credits'] = 1000; // This is the default number of credits users will have upon registeration.

$_CONFIG['hotel']['pixels'] = 999999999; // This is the default number of pixels users will have upon registeration.

$_CONFIG['hotel']['figure'] = 'hd-209-28.lg-270-92.ch-210-92'; // This is the default avatar-look that users will have upon register.

$_CONFIG['hotel']['web_build'] = '63_1dc60c6d6ea6e089c6893ab4e0541ee0/527'; // Hotel's web_build, do NOT edit this.

$_CONFIG['hotel']['external_vars'] = 'localhost/swf/gamedata/external_variables.txt'; // URL to your external_variables.txt file.

$_CONFIG['hotel']['external_texts'] = 'localhost/swf/gamedata/external_flash_texts.txt'; // URL to your external_flash_texts.txt file.

$_CONFIG['hotel']['product_data'] = 'localhost/swf/gamedata/productdata.txt'; // URL to your productdata.txt file.

$_CONFIG['hotel']['furni_data'] = 'localhost/swf/furnidata.xml'; // URL to your furnidata.xml file.

$_CONFIG['hotel']['swf_folder'] = 'localhost/swf/gordon/PRODUCTION-201709052204-426856518'; // URL to your PRODUCTION folder.

/*
*
*    Templating Management - Add an existing theme or add your own and configuring it below!
*
*/

$_CONFIG['template']['style'] = 'Sleek';

?>
I have removed db name and password for now.
 

Johno

:: xHosts :: www.xhosts.uk
Sep 12, 2011
581
246
Have you tried to set this


$_CONFIG['mysql']['connection_type']

as mysqli instead ?

These are guesses as I have not looked at any retros really in 5 + years
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
426
642
Change:
Code:
$this->connect($_CONFIG['mysqli']['connection_type']);

To:
Code:
$this->connect($_CONFIG['mysql']['connection_type']);

You're calling for a mysqli variable that doesn't exist in your config file.
 

LouisJW

Active Member
May 20, 2020
139
53
Change:
Code:
$this->connect($_CONFIG['mysqli']['connection_type']);

To:
Code:
$this->connect($_CONFIG['mysql']['connection_type']);

You're calling for a mysqli variable that doesn't exist in your config file.

$this->connect($_CONFIG['mysql']['connection_type']); My code is this, I changed back. Problem fixed now anyway thank you all for responses.
 

Users who are viewing this thread

Top