Parse error: syntax error, unexpected T_DNUMBER in /home/a2442560/public_html/s1/install/include/database.php on line 30
PHP Code:
<?php
/******Database.php*******
-- Class MYSQL_DB and MYSQLi_DB consists of the database releated functions of Travian Clone installation
-- Revision: Beta 4
-- Author: akakori
-- Homepage: -
-- Beta Server: -
-- Please do not remove this section
************************/
include("constant.php");
class MYSQLi_DB {
var $connection;
function MYSQLi_DB() {
$this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die(mysqli_error());
}
function query($query) {
return $this->connection->query($query);
}
};
class MYSQL_DB {
var $connection;
function MYSQL_DB() {
$this->connection = mysql_connect(mysql9.**********.com, a2442560_travian, 5023roderick) or die(mysql_error());
mysql_select_db(a2442560_travian, $this->connection) or die(mysql_error());
}
You need to put quotes around each string literal value you are using as function parameters in that line (and the next line).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
The error message is telling you that at that point, $database->connection is not an object. It does not tell you why though. Since you are using the dreaded "global" for the $database variable, at that point you are totally dependent on something else in the main script having properly created the $database object with the necessary $connection property. This illustrates some of the reasons the use of "global" is generally not recommended: tight dependencies between discrete parts of the code and difficulty in testing. (The immediate "fix" would be to instantiate your database class as an object named $database before you instantiate $process.
A better approach might be to pass the required database object as a parameter of your constructor and store it as a class variable, then access it within the methods as $this->database->connection, for example. Alternatively you could instantiate the $database object within the constructor itself, if you're OK with each instance of this class instantiating its own database object.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks