如何发布脚本mysql

时间:2015-06-05 08:53:14

标签: php mysql

如果我用我的cms发布脚本,人们无法读取它,它会以文本形式进入数据库

像这样:

<script>
			// Source: http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/
			var loadCSS = function(url, callback){
				var link = document.createElement('link');
				link.type = 'text/css';
				link.rel = 'stylesheet';
				link.href = url;
				link.id = 'theme-style';

				document.getElementsByTagName('head')[0].appendChild(link);

				var img = document.createElement('img');
				img.onerror = function(){
					if(callback) callback(link);
				}
				img.src = url;
			}

			$(document).ready(function() {
				var initEditor = function() {
					$("textarea").sceditor({
						plugins: 'bbcode',
						style: "./minified/jquery.sceditor.default.min.css"
					});
				};

				$("#theme").change(function() {
					var theme = "./minified/themes/" + $(this).val() + ".min.css";

					$("textarea").sceditor("instance").destroy();
					$("link:first").remove();
					$("#theme-style").remove();

					loadCSS(theme, initEditor);
				});

				initEditor();
			});
		</script>

但我怎么能知道它可以在网站上阅读?

我使用这个mysql查询:

INSERT INTO categorie (title, longstory, shortstory, date, author, categorie, type,img) VALUES('{$title}','" . htmlspecialchars_decode($longstory) . "','{$shortstory}','" . time() . "','". $_SESSION['user']['username'] ."','{$categorie}','{$type}','{$img}')";

我用来发布一个脚本:" . htmlspecialchars_decode($longstory) . "

1 个答案:

答案 0 :(得分:2)

要使用mysql(i)_real_escape_string转义数据库(字符串/文本)输入。

当您将此代码放入您的网站时,

htmlspecialchars会在输出中使用。