witam,
mam taki kod w index.php:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
echo '<h1>Tekst</h1>';
include_once('class/simpleCMS.php');
$obj = new simpleCMS();
$obj->host = 'localhost';
$obj->username = 'root';
$obj->password = '';
$obj->table = 'panel';
$obj->connect();
$obj->display_public();
?>
</body>
</html>
i taki w simpleCMS.php:
<?php
class simpleCMS {
var $host;
var $username;
var $password;
var $table;
public function display_public() {
$q = "SELECT * FROM panele";
$r = mysql_query($q);
if ( $r !== false && mysql_num_rows($r) > 0 ) {
while ( $a = mysql_fetch_assoc($r) ) {
$title = stripslashes($a['Title']);
$bodytext = stripslashes($a['bodytext']);
$entry_display .= <<<ENTRY_DISPLAY
<h2>$title</h2>
<p>
tekss
</p>
ENTRY_DISPLAY;
}
} else {
$entry_display = <<<ENTRY_DISPLAY
<h2>This Page Is Under Construction</h2>
<p>
No entries have been made on this page.
Please check back soon, or click the
link below to add an entry!
</p>
ENTRY_DISPLAY;
}
return $entry_display;
}
public function connect() {
mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
mysql_select_db($this->table) or die("Could not select database. " . mysql_error());
}
}
?>
wyświetla się tylko napis "Tekst" ze znacznika h1, co jest źle? gdyby nie mogło się połączyć z bazą danych to z tego kodu wynika, że też coś dodatkowego by wypisało, a tutaj nic..