I follow this instruction https://devcenter.heroku.com/articles/cleardb#using-cleardb-with-php
to connect my php app(deployed on heroku) to clearDb addons.
class Conn{
private $server;
private $database;
private $username;
private $password;
function __construct(){
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$this->$server = $url["host"];
$this->$username = $url["user"];
$this->$password = $url["pass"];
$this->$database = substr($url["path"], 1);
}
function connection(){
mysqli_report(MYSQLI_REPORT_STRICT);
try{
$mysqli = new mysqli($this->server, $this->username, $this->password, $this->database);
}
catch (Exception $e ) {
echo file_get_contents("Pagine/ContattiInizio.xhtml");
echo "message: " . $e->getMessage(); //This show a "no such a file or directory" error
exit;
}
return $mysqli;
}
}
new mysqli() throw up an error that I dont really understand "no such a file or directory" and I dont really kwon what to do with that.
EDIT: I tried to connect to my db with tools like dbheaver and it works fine