2012-01-03 12 views
2
mysql_query (" 
    INSERT INTO items 
    (index, name, description, given_by, 
    cost_to_tcs, starting_bid, auction_type) 
    VALUES 
    ('{$index_number}','{$name}','{$description}','{$donated_by}', 
    NULL,'{$auction_type}','{$starting_bid}') 
    ") 
    or die("3: " . mysql_error()); 

エラーと:このmysqlクエリで何が原因ですか?

3:あなたは、あなたのSQL構文でエラーが発生しています。 「index」、「name」、「description」、「given_by」、「cost_to_tcs」、「starting_bid」、1行目「auct」の近くで使用する正しい構文については、MySQLサーバーのバージョンに対応するマニュアルを参照してください。

ありがとうございました。

mysql_query (" 
INSERT INTO items (
    `index`, 
    `name`, 
    `description`, 
    `given_by`, 
    `cost_to_tcs`, 
    `starting_bid`, 
    `auction_type`) 
VALUES(
    '$index_number', 
    '$name', 
    '$description', 
    '$donated_by', 
    NULL, 
    '$auction_type', 
    '$starting_bid') 
") 
or die("3: " . mysql_error()); 

も安全なデータを確認してください。

答えて

8

indexはそのようにしてみてください(バックチック) `` `

INSERT INTO items 
(`index`, `name`, `description`, `given_by`, 
    `cost_to_tcs`, `starting_bid`, `auction_type`) 

Reserve key words

+1

ありがとうございます!それ以来、私は壁に頭を打つのを止めることができます! – lampwins

1

indexをラップし、MySQLの予約語でありますwith mysql_real_escape_string();

関連する問題