SQL不是怕 ' 或 "吗?把这个添加到数据库就要出错~~要过滤~~
我用了FCK~,用str_replace()过滤没有效果!!数据添加不进数据库[有单或双引号时候]
不知道问题出那里~~??
我应该怎么办?
代码在下面::
----------------------------------------------------------
<html>
<head>
<title>haha</title>
<script language="javascript">
function buweikong(){
sb1=document.hehe.uid.value
sb2=document.hehe.re.value
if(sb1==""||sb2==""){
alert("sb");
return false;
}
}
</script>
</head>
<body>
<?php
include("../conn.php");
include('fckeditor.php');
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = dirname($sBasePath).'/';
$ed= new FCKeditor('con');
$ed->BasePath=$sBasePath;
?>
<?php
if($_GET["sumbit"]){
$_GET["con"]=str_replace("'","‘",str_replace('"','“',$_GET["con"]));
$sql = "INSERT INTO test ( uid ,regdate,re,mess) VALUES ( '". $_GET["uid"]."',now(), '".$_GET["re"]."','".$_GET["con"]."')";
$result = mysql_query($sql);
if(mysql_insert_id()>0)
{
echo "发表成功!";
}
else
{
echo "发表失败!";
}
}
?>
<form action="jia.php" method="GET" name="hehe" onSubmit='return buweikong();'>
用户:
<input type="text" size="10" name="uid" />
标题:
<input type="text" size="10" name="re" />
<br/>
<?php $ed->Value="haha";?>
<?php $ed->Create();?>
<input type="submit" name="sumbit" value="提交" />
</form>
</body>
</html>
我用了FCK~,用str_replace()过滤没有效果!!数据添加不进数据库[有单或双引号时候]
不知道问题出那里~~??
我应该怎么办?
代码在下面::
----------------------------------------------------------
<html>
<head>
<title>haha</title>
<script language="javascript">
function buweikong(){
sb1=document.hehe.uid.value
sb2=document.hehe.re.value
if(sb1==""||sb2==""){
alert("sb");
return false;
}
}
</script>
</head>
<body>
<?php
include("../conn.php");
include('fckeditor.php');
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = dirname($sBasePath).'/';
$ed= new FCKeditor('con');
$ed->BasePath=$sBasePath;
?>
<?php
if($_GET["sumbit"]){
$_GET["con"]=str_replace("'","‘",str_replace('"','“',$_GET["con"]));
$sql = "INSERT INTO test ( uid ,regdate,re,mess) VALUES ( '". $_GET["uid"]."',now(), '".$_GET["re"]."','".$_GET["con"]."')";
$result = mysql_query($sql);
if(mysql_insert_id()>0)
{
echo "发表成功!";
}
else
{
echo "发表失败!";
}
}
?>
<form action="jia.php" method="GET" name="hehe" onSubmit='return buweikong();'>
用户:
<input type="text" size="10" name="uid" />
标题:
<input type="text" size="10" name="re" />
<br/>
<?php $ed->Value="haha";?>
<?php $ed->Create();?>
<input type="submit" name="sumbit" value="提交" />
</form>
</body>
</html>
解决方案 »
- 求一个iis下的rewrite规则
- 为什么PHP 5.2.3 没有php5apache2_2.dll这个文件呢?
- 为什么Rewrite规则一条生效一条失效
- 正则表达式问题
- dede系统制作的3322游戏站www.3322.cc要怎么样才能弄懂程序
- 請問用 Php 如何將 xml 文件轉換為 utf-8 格式﹖
- php入门语句
- 急急急。。。。有谁做过iwebsns的二次开发呢!?
- 类似中关村在线,或者太平洋汽车 多属性搜索是怎么做的,怎样的思路
- 工厂有个需求:在完工产品上贴上一个标签,标签内容就是操作员在做完该产品时当下的时间,目的是产品追溯,目前我们的解决方案:是在员工作业区放一台电脑,安装一台条码
- 急 这段代码加密了的 不知道用什么加的 谁能解吗?
- php调用其他网站内代码的问题
function formatStr($str){
$pos = strpos($str,"'");
if($pos==false) $str = str_replace("","'",$str);
else{
$str = str_replace("'","",$str);
$str = str_replace("","'",$str);
}
return trim($str);
}
$_GET["con"]=mysql_real_escape_string("'","‘",mysql_real_escape_string('"','“',$_GET["con"]));结果不可以啊~~~