hallo zusammen
hab mich in letzter zeit ein bisserl am php coden probiert, lief auch recht gut bis jetzt. nur jetzt weiß ich nicht mehr weiter. ich hab eine Klasse geschrieben, doch wenn ich variablen übergeben will, streikt er. das seltsame ist, es ging gerade noch vor 1/2 stunde oder so und auf einmal nicht mehr, ohne dass mir auch nur im geringsten klar wäre, was ich geändert haben könnte.
Der Error:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ')' in E:\Programme\XAMP\xampp\htdocs\CMS\classes\class.mysql.php on line 10
Der Code:
Code:
<?php
class db {
var $host = config::sql_host;
var $user = config::sql_user;
var $pw = config::sql_pw;
var $db = config::sql_db_name;
function __construct($this->host, $this->user, $this->pw, $this->db) {
$this->connect ($this->host, $this->user, $this->pw, $this->db);
}
function __destruct() {
@ mysql_close ($this->connid);
}
function connect($host, $user $pw, $db) {
$this->connection = @ mysql_connect ($host, $user, $pw); or die ("Keine Connection");
$this->select_db($db);
}
function select_db($db) {
mysql_select_db($db, $this->connection)) or die ("Konnte DB nicht auswählen");
}
function query($query) {
$this->result = mysql_query ($query, $this->connection) or die ("Fehler in der Query");
return $this->result;
}
}
include "..\config.php";
$test = new db ();
?>
die config.php schaut so aus: (ohne kommentare und PW natürlich)
Code:
class config {
const sql_host = 'localhost';
const sql_db_name = "rtcms";
const sql_user = "root";
const sql_pw = "sag ich nicht";
const sql_tbl_pref = "rtcms_";
}