如何将javascript插入mysql数据库? [英] How to insert javascript into mysql database?

查看:132
本文介绍了如何将javascript插入mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试插入javascript链接时遇到此问题

I'm facing this issue when i try to insert an javascript link

Database error 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near 'text/javascript'   
src='http://www.domain.com/js/embed.js'></script>'' at line 3

除了javascript链接,它接受了文本和youtube嵌入式代码。如何纠正这个问题?

Besides that javascript link, it accepted the text and youtube embedded code too . How to rectify this issue ?

这里是表

 CREATE TABLE IF NOT EXISTS `livedata` (
`livedata_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`livedata_cat_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`code` text NOT NULL,
 PRIMARY KEY (`livedata_id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=78 ;

我的Htm代码

 <textarea class="text-input textarea" id="textarea" name="code" cols="100" rows="8"></textarea>


推荐答案

不评论你实际在做什么,但你的问题出在撇号上。使用 mysql_real_escape_string 来逃避它们。

Not commenting on what you are actually doing, but your problem is in the apostrophes. Do escape them using mysql_real_escape_string.

这篇关于如何将javascript插入mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆