Kod: Markera allt
class TPostContent {
// Variable for entering the blogg
var $Title;
var $Date;
var $Content;
// db variable
var $dbConnection;
var $db;
var $query;
function __construct ( $aTitle, $aDate, $aContent ) {
$this->Title = $aTitle;
$this->Date = $aDate;
$this->Content = $aContent;
$this->dbConnection = mysql_connect("localhost", "user", "< cencur ;-) >") or die("mysql error: " . mysql_error());
$this->db = mysql_select_db("Blogg1", $this->dbConnection ) or die("mysql error: " . mysql_error());
$this->query = "INSERT INTO BloggPost (Title, Date, Content) VALUES ('{$Title}', '{$Date}', '{$Content}')";
mysql_query($this->query);
}
function __destruct() {
mysql_close($this->$dbConnection);
}
}
Kod: Markera allt
$Blogg = new TPostContent("En titlel", "idag", "En massa text och min livs historia");
Kod: Markera allt
unset($Blogg);