首页 > 解决方案 > 删除 # OR 第一行数据允许我将它输入到数据库中吗?

问题描述

所以,我建立了一个新的数据库和一个表,没什么花哨的,只是一个快速的马虎 mysql 数据库,现在已经足够好了:

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

CREATE TABLE `cards` (
  `ID` int(11) NOT NULL,
  `Name` varchar(32) NOT NULL,
  `setNumber` int(3) NOT NULL,
  `setYear` varchar(10) NOT NULL,
  `setName` varchar(64) NOT NULL,
  `setCode` varchar(10) NOT NULL,
  `owned` int(1) NOT NULL,
  `goal` int(1) NOT NULL,
  `rarity` varchar(16) DEFAULT NULL,
  `atribute` varchar(8) NOT NULL,
  `level` int(2) DEFAULT NULL,
  `race` varchar(16) DEFAULT NULL,
  `special` varchar(8) DEFAULT NULL,
  `type` varchar(8) DEFAULT NULL,
  `atk` int(4) DEFAULT NULL,
  `def` int(4) DEFAULT NULL,
  `text` text NOT NULL,
  `link` varchar(128) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


ALTER TABLE `cards`
  ADD PRIMARY KEY (`ID`);

ALTER TABLE `cards`
  MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

这是有趣的部分:

我尝试用一​​些数据填充表格:

INSERT INTO `cards` (`ID`, `Name`, `setNumber`, `setYear`, `setName`, `setCode`, `owned`, `goal`, `rarity`, `atribute`, `level`, `race`, `special`, `type`, `atk`, `def`, `text`, `link`) VALUES 
(NULL, 'Skull Servant','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','DARK','1','Zombie','','Normal','300','200','A skeletal ghost that isn\'t strong but can mean trouble in large numbers.','foff?ope=2&cid=4030'),
(NULL, 'Dark Magician','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','Ultra Rare','DARK','7','Spellcaster','','Normal','2500','2100','The ultimate wizard in terms of attack and defense.','foff?ope=2&cid=4041'),
(NULL, 'Gaia The Fierce Knight','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','Ultra Rare','EARTH','7','Warrior','','Normal','2300','2100','A knight whose horse travels faster than the wind. His battle-charge is a force to be reckoned with.','foff?ope=2&cid=4044'),
(NULL, 'Celtic Guardian','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','Super Rare','EARTH','4','Warrior','','Normal','1400','1200','An elf who learned to wield a sword, he baffles enemies with lightning-swift attacks.','foff?ope=2&cid=4047'),
(NULL, 'Basic Insect','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','EARTH','2','Insect','','Normal','500','700','Usually found traveling in swarms, this creature\'s ideal environment is the forest.','foff?ope=2&cid=4056'),
(NULL, 'Mammoth Graveyard','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','EARTH','3','Dinosaur','','Normal','1200','800','A mammoth that protects the graves of its pack and is absolutely merciless when facing grave-robbers.','foff?ope=2&cid=4065'),
(NULL, 'Silver Fang','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','EARTH','3','Beast','','Normal','1200','800','A snow wolf that\'s beautiful to the eye, but absolutely vicious in battle.','foff?ope=2&cid=4071'),
(NULL, 'Dark Gray','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','EARTH','3','Beast','','Normal','800','900','Entirely gray, this beast has rarely been seen by mortal eyes.','foff?ope=2&cid=4119'),
(NULL, 'Trial of Nightmare','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','DARK','4','Fiend','','Normal','1300','900','This fiend passes judgment on enemies that are locked in coffins.','foff?ope=2&cid=4125'),
(NULL, 'Nemuriko','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','DARK','3','Spellcaster','','Normal','800','700','A child-like creature that controls a sleep fiend to beckon enemies into eternal slumber.','foff?ope=2&cid=4135'),
(NULL, 'The 13th Grave','1','03/08/2002','LEGEND OF BLUE EYES WHITE DRAGON','','0','3','','DARK','3','Zombie','','Normal','1200','900','A zombie that suddenly appeared from plot #13 - an empty grave.','foff?ope=2&cid=4138');

它把这个扔在我的脸上:

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取正确的语法,以便在第 12 行的“从情节中突然出现的僵尸”附近使用

所以我想“哦,好吧,我会在几秒钟内解决这个问题”——但没有什么特别突出的。所以我去检查错误消息并想“好吧,那不可能,可以吗?” 但果然,# 符号导致了错误。这……我觉得很奇怪。

不管怎样,我分心了,然后回到电脑前,试着从我离开的地方继续,所以我复制了我插入的数据,但这次我漏掉了第一行,(骷髅仆人),忘记删除#签名...并且该代码有效!

问题是......如何删除一段文本中的 # 符号使代码工作 - 或者保留该 # 符号并删除第一行?

我一遍又一遍地经历它,我输入的数据看起来并不奇怪或有任何突出的东西,所以这怎么可能呢?

我开始认为鬼要为这种奇怪的行为负责。请向我解释这种奇怪的行为,因为我真的不知道如何解决它。

标签: mysqlinputhashtag

解决方案


推荐阅读