2
我有一个MySQL数据库和所有的PHP插入值,其余的工作,但我的聊天没有。PHP不会插入聊天消息
我的主机不允许我看到MySQL错误日志,所以我不能通过它看到什么是错的。
<?php
session_start();
include 'default.php';
include 'SteamAuthentication/steamauth/userInfo.php';
$db = getDB();
if (!isset($_SESSION['steamid'])) {
echo jsonErr('You are not logged in.');
return;
}
$text = isset($_POST['text']) ? $_POST['text'] : null;
if (is_null($text) || strlen($text) === 0) {
echo jsonErr('The required text for the message was not sent correctly or was left blank. Please refresh and try again.');
return;
}
$steamUserID = $steamprofile['steamid'];
$stmt = $db->prepare('INSERT INTO chat (steamUserID, `text`, `date`, `time`) VALUES (:userid, :text, CURDATE(), CURTIME())');
$stmt->bindValue(':userid', $steamUserID);
$stmt->bindValue(':text', $text);
$stmt->execute();
echo jsonSuccess(array('message' => 'Message has been sent!'));
?>
作注,我的其他PHP文件可以插入到我的数据库就好了,所以它不是数据库配置,有没有我的代码的问题吗?
尝试在查询和用户标识符上显示回显,如果查询有问题,您将看到文本 –