Ok, I didn`t go to sleep. I continued to try to fix my error, but I`m still stuck. I wrote down the things new way using PDO, but now I got a new error:
$file = "/root/.my.cnf";
$lines = file($file);
list($password, $pass) = explode("=", $lines[1]);
class Database{
// specify your own database credentials
private $host = "127.0.0.1";
private $db_name = "root_cwp";
private $username = "root";
private $password = $pass; -> Line 13 making the error;
public $conn;
// get the database connection
public function getConnection(){
$this->conn = null;
try{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
}catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
And in one moment:
Fatal error: Constant expression contains invalid operations in /usr/local/cwpsrv/htdocs/resources/admin/modules/database.php on line 13
Never got an error like that before, so please somebody help me with it.