PDO を使用して、いくつかの値を持つフォームを MySQL データベースに挿入しようとしています。
/*** Values for the form ***/
$date = date_create();
$time = date('Y-m-d H:i:s');
$message = $_POST['message'];
$uid = $_SESSION['SESS_MEMBER_ID'];
$admin = 1;
/*** prepare the SQL statement ***/
$stmt = $db->prepare("INSERT INTO messages (message_id, timestamp, uid, admin, read, edited, message) VALUES ('',':time',':uid',':admin','','',':message')");
/*** bind the paramaters ***/
$stmt->bindParam(':time', $time, PDO::PARAM_STR);
$stmt->bindParam(':uid', $uid, PDO::PARAM_STR);
$stmt->bindParam(':admin', $admin, PDO::PARAM_INT, 1);
$stmt->bindParam(':message', $message, PDO::PARAM_STR);
/*** execute the prepared statement ***/
$stmt->execute();
結果は次のとおりです:
message_id のみが設定された空のエントリと、まだプレースホルダー :mesagge を持つメッセージ
(message_id, timestamp, uid, admin, read, edited, message)
15 | 0000-00-00 00:00:00 | 0 | 0 | 0 | 0 |:bericht
プレースホルダーまたは INSERT クエリの何が問題になっていますか?