I need help with a problem that has stumped me for days. It's probably an obvious answer and may have been answered before. And as a prerequisite, I have done much googling and stack crawling, to no avail. Being honest, I'm not sure what the problem IS. Any help is greatly appreciated and will hopefully save others in my peculiar situation some premature baldness. So without further Ado, here is the code:
Code - db.php
class Database {
private function host() {
return 'localhost:3306';
}
private function user() { // line 8 is here
return "root";
}
private function password() {
return "";
}
private function dbname() {
return "stonelabs";
}
private $dbh;
private $error;
public function __construct() {
$dsn = 'mysql:host=' . $this->host() . ';dbname=' . $this->dbname();
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
try{
$this->dbh = new PDO($dsn, $this->user(), $this->password(), $options);
return true;
}
catch(PDOException $e){
$this->error = $e->getMessage();
return false;
}
}
}
And here is the error I'm receiving:
Error - In Browser
Parse error: syntax error, unexpected ' private' (T_STRING), expecting function (T_FUNCTION) in /storage/emulated/0/var/www/Stone Info Labs/test/core/core/helpers/db.php on line 8
I'm trying to make a simple PDO database class, have done many times before, simply won't work. This class file is required into the index file (which is only 4 lines, opening php bracket, and 3 require lines, all of which worked until this stage). I'm developing and running on Android 6.0.1, using the lighttpd server provided by servers ultimate pro, again, all of which worked until this, including previous websites.
Edit
I am using php version 5.5
Another Edit
I changed $this->pass() to $this->password() with the same errors. Code above has been updated