为什么MySQL插入' & # 39;在我的链接之前


Why is MySQL inserting ' ' before my links?

当我通过PHP表单插入链接时,我的数据库会在链接之前放反斜杠。我用tinyMCE。

示例,这是它在数据库中的样子:

(14, 'MULTIMÉDIA', 'multimdia', '<h2><strong>RISING HARMONY&nbsp;</strong></h2>'r'n<p><strong>ITT A ZENE VIL&Aacute;GA URALKODIK.</strong></p>'r'n<p><strong>KEDVENC&Eacute;T &Ouml;N IS MEGOSZTHATJA&nbsp;</strong><strong>AZ AL&Aacute;BBI C&Iacute;MEN:</strong></p>'r'n<p><strong><a href=''"''''&quot;''''''''&quot;''''''''''''''''&quot;mailto:personicum@gmail.com''''''''''''''''&quot;''''''''&quot;''''&quot;''">personicum@gmail.com</a> &nbsp;</strong></p>', '<p><iframe src=''"''''&quot;''''''''&quot;''''''''''''''''&quot;/www.youtube.com/embed/1ov6USLXwGA''''''''''''''''&quot;''''''''&quot;''''&quot;''" width=''"''''&quot;''''''''&quot;''''''''''''''''&quot;270''''''''''''''''&quot;''''''''&quot;''''&quot;''" height=''"''''&quot;''''''''&quot;''''''''''''''''&quot;152''''''''''''''''&quot;''''''''&quot;''''&quot;''" frameborder=''"''''&quot;''''''''&quot;''''''''''''''''&quot;0''''''''''''''''&quot;''''''''&quot;''''&quot;''" allowfullscreen=''"allowfullscreen''"></iframe>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<iframe src=''"''''&quot;''''''''&quot;''''''''''''''''&quot;/www.youtube.com/embed/bnv6dPQ5f88''''''''''''''''&quot;''''''''&quot;''''&quot;''" width=''"''''&quot;''''''''&quot;''''''''''''''''&quot;263''''''''''''''''&quot;''''''''&quot;''''&quot;''" height=''"''''&quot;''''''''&quot;''''''''''''''''&quot;150''''''''''''''''&quot;''''''''&quot;''''&quot;''" frameborder=''"''''&quot;''''''''&quot;''''''''''''''''&quot;0''''''''''''''''&quot;''''''''&quot;''''&quot;''" allowfullscreen=''"allowfullscreen''"> )

这应该是一个youtube视频,通过tinyMCE插入。它对图像和任何类型的链接做同样的事情。我的问题是,为什么这些东西会出现?

表格如下:

CREATE TABLE IF NOT EXISTS `blog_posts_seo` (
`postID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`postTitle` varchar(255) DEFAULT NULL,
`postSlug` varchar(255) DEFAULT NULL,
`postDesc` text,
`postCont` text,
`postDate` datetime DEFAULT NULL,
PRIMARY KEY (`postID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;

与另一个表,它工作得很好,所以这意味着问题不是与我的php,但我会复制它在这里,如果它是需要的。这个问题是由什么引起的?在网站上有一个404错误而不是视频。

如果我通过MySQL手动插入它们,那么一切都很好,但是如果我通过表单插入它,它看起来像这样。此外,如果我使用相同的php与另一个数据库,它的工作很好。这是一个悖论,我没有经验。我找不到问题。

同样,在局部也可以正常工作,它显示如下:

<p><iframe src="//www.youtube.com/embed/Lcu8SdcsYnY" width="425" height="350"></iframe></p>

谢谢你,提前。

对输入多次运行addslashes()或其他转义函数。你可能也有魔术引号。您应该保持原始字符串,并且只在插入数据库之前转义它们。最好使用PDO的绑定参数