ChristianKl1
Grünschnabel
Sehr geehrte Damen und Herren,
ich bin in der PHP Klassenprogrammierung noch relativ neu.
ms.class.php:
index.php:
Folgende Probleme erscheinen beim Aufruf der Datei index.php:
(betrifft connect-funktion)
Jetzt bin ich ratlos wie ich diese Probleme behebe, es liegt vielleicht daran, dass die Variablen $host, $user, $passwort und $database nicht korrekt definiert wurden, ich hab jetzt aber kein Plan wie ich das am besten mache.
Wäre euch sehr dankbar wenn Ihr mir dabei helfen könntet.
Vielen Dank im Voraus
Gruß
Christian
ich bin in der PHP Klassenprogrammierung noch relativ neu.
ms.class.php:
HTML:
<?php
include('Smarty.class.php');
Class ms_marketing extends Smarty{
private $conn;
private $result;
public $host = 'localhost';
public $user = 'root';
public $password = '';
public $database = 'datenbank';
public function __construct()
{
$this->ms_connect($host, $user, $password, $database);
}
public function ms_connect($host, $user, $password)
{
// Verbindungsaufbau zum Datenbankserver
$this->conn = mysqli_connect($host, $user, $password, $database);
// mysqli_select_db($database, $this->conn);
}
public function ms_disconnect()
{
// Verbindung zum Datenbankserver abbauen
if(is_resource($this->conn))
{
mysqli_close($this->conn);
}
}
public function ms_query($query)
{
if(is_resource($this->conn)) {
if(is_resource($this->result)) {
mysql_free_result($this->result);
}
$this->result = mysqli_query($query, $this->conn);
}
}
public function ms_fetchRow() {
if(is_resource($this->result)) {
$row = mysqli_fetch_assoc($this->result);
if(is_array($row)) {
return $row;
}
else {
return FALSE;
}
}
}
public function __destruct()
{
$this->ms_disconnect();
}
}
index.php:
HTML:
<?php
include('inc/variables.inc.php');
include(SMARTY_DIR.'ms.class.php');
$smarty = new ms_marketing($host, $user, $password);
$smarty->assign("titel","M&S Marketing und Medien");
$smarty->display("index.tpl");
?>
Folgende Probleme erscheinen beim Aufruf der Datei index.php:
(betrifft connect-funktion)
HTML:
Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'ODBC'@'localhost' (using password: NO) in G:\xampp\xampp\htdocs\php5-ms\libs\ms.class.php on line 29
HTML:
Warning: mysqli_select_db() expects parameter 1 to be mysqli, null given in G:\xampp\xampp\htdocs\php5-ms\libs\ms.class.php on line 31
Wäre euch sehr dankbar wenn Ihr mir dabei helfen könntet.
Vielen Dank im Voraus
Gruß
Christian