私のデータベースにデータを置く非常に(おそらく)簡単なコードを書くことを試みています。私のSQL構文でエラーがテーブルに挿入することができません
4, 14, 2, 2016-04-26, 23:00:00, 05:00:00, 05
誰が問題にいくつかの光を当てることができます。
$sql = "INSERT INTO `clubevent` (clubevent_id ,club_id ,event_id ,theme_id ,clubevent_date ,clubevent_start_time ,clubevent_finish_time ,clubevent_cost) VALUES (NULL , $clubstate, $eventstate, $themestate, $datestate, $sTimestate, $fTimestate, $coststate)";
しかし、私は常に
Error: INSERT INTO
clubevent
(clubevent_id ,club_id ,event_id ,theme_id ,clubevent_date ,clubevent_start_time ,clubevent_finish_time ,clubevent_cost) VALUES (NULL , 4, 14, 2, 2016-04-26, 23:00:00, 05:00:00, 05) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':00:00, 05:00:00, 05)' at line 1
はこのに取得しようとしたデータイムがあるというメッセージを取得していますか?
引用エラーがあります。準備されたステートメントを使用すると、この問題は発生しません。 –
私は同意し、解決するために準備された声明を使用します。あなたの日付/時間がエスケープされていないため、あなたの問題がある理由が言われています。セミコロンを読み込んでエラーが発生する – Doug
これがSQL Serverの場合、なぜmysqlとしてタグ付けしますか? – e4c5