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());
错误:
3:您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以便在''index','name','description','given_by','cost_to_tcs','starting_bid','auct'附近的第1行使用正确的语法
感谢您的帮助。
答案 0 :(得分:8)
index
是mysql保留关键字,用{back tick}包裹index
```
INSERT INTO items
(`index`, `name`, `description`, `given_by`,
`cost_to_tcs`, `starting_bid`, `auction_type`)
答案 1 :(得分:1)
尝试:
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_real_escape_string();