私は個人的な使用のために小さな Twitter クローンを構築していますが、それにはとても苦労しています。まず、テーブル「poke_history」の SQL 構造をお見せしたいと思います:
http://puu.sh/3Sci0.png
これは、値を (PHP で) テーブルに挿入するために使用するコマンドです。
$insert = "INSERT INTO poke_history (id, from, time, reason) VALUES ('".$to_id."', '".$from_id."', '".$time."', '".$reason."')";
mysql_query($insert) or die(mysql_error());
これは私が得ている厄介なエラーです:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, time, reason) VALUES ( '1'' at line 3.
いくつかのことを明確にさせてください。
$to_id
は数字です。
$from_id
は数字です。
$time
は数値です (PHP の から取得time()
)。
$reason
はテキスト文字列です。
MySQL と PHP5 を使用しています。