Handle exceptions.
This commit is contained in:
37
chat.php
37
chat.php
@@ -15,28 +15,25 @@ include_once "config.php";
|
||||
$msg = filter_input(INPUT_POST,'msg');
|
||||
$uid = $_SESSION['uid'];
|
||||
if ($msg) {
|
||||
try {
|
||||
db::c()->query('INSERT INTO `chat` (`uid`, `msg`) VALUES (?i, "?s")', $uid, $msg);
|
||||
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||
echo "DB Error: ". $e->getMessage() . PHP_EOL;
|
||||
echo "File: " . $e->getFile() . "[".$e->getLine()."]". PHP_EOL;
|
||||
}
|
||||
mysql_error_handler(db::c()->query('INSERT INTO `chat` (`uid`, `msg`) VALUES (?i, "?s")', $uid, $msg));
|
||||
}
|
||||
|
||||
function show_messages()
|
||||
{
|
||||
try {
|
||||
$chat = db::c()->query('
|
||||
SELECT
|
||||
`msg`,
|
||||
`msgdate`,
|
||||
(SELECT `login` FROM `users` WHERE `users`.`id` = `uid`) AS `from`,
|
||||
`type`
|
||||
FROM `chat` ORDER BY `id` LIMIT 50');
|
||||
} catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||
echo "DB Error: ". $e->getMessage() . PHP_EOL;
|
||||
echo "File: " . $e->getFile() . " (".$e->getLine().")". PHP_EOL;
|
||||
}
|
||||
function show_messages(){
|
||||
mysql_error_handler($chat = db::c()->query('
|
||||
SELECT msg, msgdate, (SELECT login FROM users WHERE users.id = uid) AS from, type
|
||||
FROM `chat` ORDER BY `id` LIMIT 50'));
|
||||
// try {
|
||||
// $chat = db::c()->query('
|
||||
// SELECT
|
||||
// `msg`,
|
||||
// `msgdate`,
|
||||
// (SELECT `login` FROM `users` WHERE `users`.`id` = `uid`) AS `from`,
|
||||
// `type`
|
||||
// FROM `chat` ORDER BY `id` LIMIT 50');
|
||||
// } catch (\Krugozor\Database\Mysql\Exception $e) {
|
||||
// echo "DB Error: ". $e->getMessage() . PHP_EOL;
|
||||
// echo "File: " . $e->getFile() . " (".$e->getLine().")". PHP_EOL;
|
||||
// }
|
||||
|
||||
while ($message = $chat->fetch_assoc()) {
|
||||
$d = new DateTime($message['msgdate']);
|
||||
|
||||
Reference in New Issue
Block a user