アプリ版:「スタンプのみでお礼する」機能のリリースについて

insert into cb001
(rec_ymd,update_ymd,update_content,scan_ymd,rig_wro,bukken_rank,loc_genru,loc_category,post_no,address_a,address_b,address_c,
buil_nm,floor_num,pay_select,parking,usage,station,on_off,route,heavy,light,mono,office,note,structure,tsubo,rent,tsubo_rent,public,
security,front,contract,condition,population,app,into,owner,contact)
values("'.$_POST['rec_ymd'].'","'.$_POST['update_ymd'].'","'.$_POST['update_content'].'","'.$_POST['scan_ymd'].'",
"'.$_POST['rig_wro'].'","'.$_POST['bukken_rank'].'","'.$_POST['loc_genru'].'","'.$_POST['loc_category'].'","'.$_POST['post_no'].'","'.$_POST['address_a'].'","'.$_POST['address_b'].'",
"'.$_POST['address_c'].'","'.$_POST['buil_nm'].'","'.$_POST['floor_num'].'","'.$_POST['pay_select'].'","'.$_POST['parking'].'",
"'.$_POST['usage'].'","'.$_POST['station'].'","'.$_POST['on_off'].'","'.$_POST['route'].'","'.$_POST['heavy'].'","'.$_POST['light'].'","'.$_POST['mono'].'",
"'.$_POST['office'].'","'.$_POST['note'].'","'.$_POST['structure'].'","'.$_POST['tsubo'].'","'.$_POST['rent'].'","'.$_POST['tsubo_rent'].'","'.$_POST['public'].'",
"'.$_POST['security'].'","'.$_POST['front'].'","'.$_POST['contract'].'","'.$_POST['condition'].'","'.$_POST['population'].'",
"'.$_POST['app'].'","'.$_POST['into'].'","'.$_POST['owner'].'","'.$_POST['contact'].'")

【エラー内容】
#1064 - 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 'usage,station,on_off,route,heavy,light,mono,office,note,structure,tsubo,rent,tsu' at line 3

何がおかしいんでしょうか?何度見ても分かりません。
以上の情報以外の部分なのでしょうか?

MySQL 5.1.33
です。

A 回答 (4件)

「usage」が予約語だからじゃないですかね。


バッククォート(`)でかこってみてください。

この回答への補足

予約語だったとは気づきませんでした。
どの部分にバッククォートをつけたらいいんでしょうか?

補足日時:2009/10/28 21:01
    • good
    • 0

ANo.1です。



`usage`とします。
予約語について、他にも使われているかは見ていません。
こちらをご参照ください。
http://dev.mysql.com/doc/refman/5.1/ja/reserved- …
    • good
    • 0

function data2InsertParam( $table, $data ) {


$names = array_keys( $data );
$values = array_map( mysql_real_escape_string, array_values( $data ) );
return "(`" . implode( "`,`", $names ) . "`) VALUES ('" . implode( "','", $values ) . "')";
}

$query = "INSERT INTO `cb001` ".data2InsertParam( $_POST );
    • good
    • 0

引数の $table 消しといて。


# だめだ、寝ぼけとる。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!