当我将记录插入mysql时,它给我错误
$sql = "insert into fish (fish_id,common_name,scientific_name,family,range,habitate,adult_size,identification,how_to_fish,image) values ('$com_name','$scientific_name','$family','$range','$habitate','$adult_size','$identification','$how_to_fish','$TARGET_PATH')";
Run Code Online (Sandbox Code Playgroud)
错误是
无法将数据插入数据库:您的SQL语法中有错误; 检查与MySQL服务器版本对应的手册,以便
range,habitate,adult_size,identification,how_to_fish,image) values ('Suwannee Ba在第1行的' ' 附近使用正确的语法
当我转储查询时,它显示所有字段都是正确的.
string(737) "insert into fish (catch_id,common_name,scientific_name,family,range,habitate,adult_size,identification,
how_to_fish,image) values ('','Suwannee Bass','Micropterus notius','Centrarchidae (Sunfish)','United States (Florida, Georgia)',
'Freshwater: found in Suwannee and Ochlockonee river drainages of Florida and Georgia.',
'Up to 12 oz (.34 kg).','The smallest of the Black Bass; brown with dark markings along back and sides. Adult male has blue cheeks, breast, and belly.',
'Natural or artificial bait such as spinners, spoons, crankbaits, surface plugs, and plastic worms. Also can be caught via fly fishing using bugs, streamers, and bucktails. Live bait includes worms, crayfish, leeches, and minnows.',
'localhost/fish/pics/Smallmouth bass.png')"
Run Code Online (Sandbox Code Playgroud)
请注意我的(catch_id)是自动增量,我检查了这一点而没有插入catch_id,但同样的问题是存在的
RANGE是一个MySQL保留字,因此你需要range在反引号中包装你的字段名,否则MySQL会感到困惑.
insert into fish (fish_id,common_name,scientific_name,family,`range`,habitate...
Run Code Online (Sandbox Code Playgroud)
然后,您可能只需将表名和所有字段名称括在反引号中.或者,重命名该range字段,这样您就不必使用反引号.
| 归档时间: |
|
| 查看次数: |
72 次 |
| 最近记录: |