• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

gesior sqlite connection error

ares413

New Member
Joined
Apr 1, 2010
Messages
130
Reaction score
3
when trying to connect to the database i get this error

Code:
Parse error: syntax error, unexpected ';', expecting T_FUNCTION in C:\xampp\htdocs\pot\OTS_DB_SQLite.php on line 68

but my ots_db_sqlite.php file reads as following:

PHP:
<?php

/**#@+
 * @version 0.0.1
 */

/**
 * @package POT
 * @version 0.1.3
 * @author Wrzasq <[email protected]>
 * @copyright 2007 (C) by Wrzasq
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
 */

/**
 * SQLite connection interface.
 * 
 * <p>
 * At all everything that you really need to read from this class documentation is list of parameters for driver's constructor.
 * </p>
 * 
 * @package POT
 * @version 0.1.3
 */
class OTS_DB_SQLite extends OTS_Base_DB
{
/**
 * Creates database connection.
 * 
 * <p>
 * Connects to SQLite database on given arguments.
 * <p>
 * 
 * <p>
 * List of parameters for this drivers:
 * </p>
 * 
 * <ul>
 * <li><var>database</var> - database name.</li>
 * </ul>
 * 
 * @version 0.0.7
 * @param array $params Connection parameters.
 * @throws PDOException On PDO operation error.
 */
    public function __construct($params)
    {
        if( isset($params['prefix']) )
        {
            $this->prefix = $params['prefix'];
        }

        // PDO constructor
	try
	{
		parent::__construct('sqlite:' . $params['database']);
	}
	catch(PDOException $error)
	{
		echo 'Can\'t connect to SQLite database.</font>';
			exit;
	}

}

/**#@-*/

?>

why wont this work? help rep ++
 
PHP:
<?php

/**#@+
 * @version 0.0.1
 */

/**
 * @version 0.1.5
 * @package POT
 * @author Wrzasq <[email protected]>
 * @copyright 2007 (C) by Wrzasq
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
 */

/**
 * This class will drop " quotes from field names in SQLite results.
 * 
 * @version 0.1.5
 * @package POT
 * @ignore
 */
class OTS_SQLite_Results extends PDOStatement
{
/**
 * Stripping single array keys.
 * 
 * @param array $record Record row.
 * @return array Record with dropped quotes from field names.
 */
    private function strip($record)
    {
        // if it's end of results
        if(!( is_array($record) || is_object($record) ))
        {
            return $record;
        }

        // our unescaped row
        $row = array();

        // strips quotes from each field
        foreach($record as $name => $value)
        {
            $row[ preg_replace('/^"?(.*?)"?$/', '\\1', $name) ] = $value;
        }

        return $row;
    }

/**
 * Removes quoting delimiters from single row fields.
 * 
 * @version 0.1.5
 * @param int $mode Not used, for PDO compatibility.
 * @param int $orientation Not used, for PDO compatibility.
 * @param int $offset Not used, for PDO compatibility.
 * @return array Records set.
 */
    public function fetch($mode = null, $orientation = null, $offset = null)
    {
        // standard output
        return $this->strip( parent::fetch() );
    }

/**
 * Removes quotes from all result rows.
 * 
 * @version 0.1.5
 * @param int $mode Not used, for PDO compatibility.
 * @param int $index Not used, for PDO compatibility.
 * @param array $args Not used, for PDO compatibility.
 * @return array Record row.
 */
    public function fetchAll($mode = null, $index = null, $args = array() )
    {
        $results = array();

        // fetches all results
        foreach( parent::fetchAll() as $index => $record)
        {
            $results[$index] = $this->strip($record);
        }

        return $results;
    }
}

/**#@-*/

?>
 
that fixed step two, and i had to change something in the ots.php file, but on step three now im getting this

Code:
Fatal error: Call to undefined method OTS_SQLite_Results::query() in C:\xampp\htdocs\install\install.php on line 231

and my install.php code is as follows starting on line 223:

PHP:
if($step == '3') 
		{
			echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
			echo 'Installer try to add new tables and columns to database.<br>';
				$config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
				if($config['server']['sqlType'] == "sqlite") 
				{
					//if sqlite
					try { $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
					try { $SQL->query('ALTER TABLE accounts ADD "email_new" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
the first try $SQL query line is where the error occurs.

helpp! rep++

- - - Updated - - -

bump
 
try this
PHP:
if($step == '3') {
		echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
		echo 'Installer try to add new tables and columns to database.<br>';
		$config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
		if($config['server']['sqlType'] == "sqlite") {
			try { $SQL->query('ALTER TABLE accounts ADD "key" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
			try { $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
			try { $SQL->query('ALTER TABLE accounts ADD "email_new" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {
 
still not working, getting this error:
Code:
Fatal error: Call to undefined method OTS_SQLite_Results::query() in C:\xampp\htdocs\install\install.php on line 228

and now heres the part of the install.php with your fix:
PHP:
if($step == '3') {
        echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
        echo 'Installer try to add new tables and columns to database.<br>';
        $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
        if($config['server']['sqlType'] == "sqlite") {
					try { $SQL->query('ALTER TABLE accounts ADD "key" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
					try { $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}


i cant figure out what the problem is i think it may have to do with changing the name of the class which got me past step 2
 
yea this is a gesior installation problem, step 1 = ok step 2 = ok step 3 =
Code:
Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\install\install.php on line 228
 
Why you use Sqlite in gesior O.o? gesior is for SQL, you edit config.lua
Code:
mysqlHost = "IP"
mysqlUser = "root"
mysqlPass = "PASS"
mysqlDatabase = "theforgottenserver.s3db"
mysqlPort = 3306
 
Back
Top