I am making a PHP blog library. I am new to web development and only really programme in C++ or Python. So, I have probably done something really stupid, but this code doesn't work:
<?php
class Blog
{
public $version = 1.0;
public $mysql = NULL;
public $servername = NULL;
public $username = NULL;
public $password = NULL;
public $dbname = NULL;
public function connectToDatabase($server, $user, $pass, $db) {
$this->$servername = $server;
$this->$username = $user;
$this->$password = $pass;
$this->$dbname = $db;
$this->$mysql = mysql_connect($this->$servername, $this->$username, $this->$password);
if (!$this->$mysql) {
die('Error 500: Internal server error. :(<br /><br />Could not connect to ' . $this->$servername . ': ' . mysql_error());
return false;
}
I get the error: Fatal error: Cannot access empty property in /home/tom/public_html/Projects/PHPBlog/blog.php on line 13