| Код | <?php
//Загружаем 'config-file' require_once('config.php');
//Загружаем модуль обработки ошибок 'error_handler' require_once('error_handler.php');
{ private $mMysqli; function __construct() { $this -> mMysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE); } public function __destruct() { $this -> mMysqli -> close(); } public function deleteMessages() { $query = 'TRUNCATE TABLE chat'; $result = $this -> mMysqli -> query($query); } public function postMessage($name, $message, $color) { $name = $this -> mMysqli -> real_escape_string($name); $message = $this -> mMysqli -> real_escape_string($message); $color = $this -> mMysqli -> real_escape_string($color); $query = 'INSERT INTO chat(posted_on, user_name, message, color)' . 'VALUES (NOW(), "' . $name . '" , "' . $message . '","' . $color . '")'; $result = $this -> mMysqli -> query($query); } public function retrieveNewMessages($id = 0) { $id = $this -> mMysqli -> real_escape_string($id); if(id > 0) { $query = 'SELECT chat_id, user_name, message, color, ' . ' DATE_FORMAT(posted_on, "%Y-%m%-d %H:%i%s")' . ' AS posted_on' . 'FROM chat WHERE chat_id > ' . $id . ' ORDER BY chat_id ASC'; } else { $query = 'SELECT chat_id, user_name, message, color, posted_on FROM' . ' (SELECT chat_id, user_name, message, color, ' . ' DATE_FORMAT(posted_on, "%Y-%m%-d %H:%i%s") AS posted_on ' . ' FROM chat ' . ' ORDER BY chat_id DESC ' . ' LIMIT 50) AS Last50' . ' ORDER BY chat_id ASC'; } $result = $this -> mMysqli -> query($query); $respone = '<?xml version = "1.0" encoding = "UTF-8" standalone = "yes"?>'; $response .= '<response>'; $response .= $this -> isDatabaseCleared($id); if($result -> num_rows) { //Добавляем все извлеченный из БД сообщения в ответ, который будет послан User'у while($row = $result -> fetch_array(MYSQLI_ASSOC)) { $id = $row['chat_id']; $color = $row['color']; $userName = $row['user_name']; $time = $row['posted_on']; $message = $row['message']; $response = '<id>' . $id . '</id>' . '<color>' . $color . '</color>' . '<time>' . $time . '</time>' . '<name>' . $userName . '</name>' . '<message>' . $color . '</message>' . } $result -> close(); } $response = $response . '</response>'; return $response; //return($response); } public function isDatabaseCleared($id) { if($id > 0) { $check_clear = 'SELECT count(*) old FROM chat where chat_id<=' .$id; $result = $this -> mMysqli -> query($check_clear); $row = $result -> fetch_array(MYSQLI_ASSOC); if($row['old'] == 0) return('<clear>true</clear>'); } return('<clear>false</clear>'); } }
?>
|
Error:| Код | Parse error: syntax error, unexpected T_PRIVATE in Z:\home\localhost\www\chat.class.php on line 21
|
Чего-то не пойму, что не нравится ему? =)
|