引号已经经过转换了
select user_id,user_passwd,user_logined from user_login where user_id = 'aa\'' AND user_passwd = 'AAAA'出错已经将'转换成了\',还是出错,双引号不会出错
select user_id,user_passwd,user_logined from user_login where user_id = '2\"' AND user_passwd = '2'不出错php.ini里面的设置magic_quotes_gpc = Off转是我自己转的,不知道那里出错
环境是php+windows+2000+mssql2005
select user_id,user_passwd,user_logined from user_login where user_id = 'aa\'' AND user_passwd = 'AAAA'出错已经将'转换成了\',还是出错,双引号不会出错
select user_id,user_passwd,user_logined from user_login where user_id = '2\"' AND user_passwd = '2'不出错php.ini里面的设置magic_quotes_gpc = Off转是我自己转的,不知道那里出错
环境是php+windows+2000+mssql2005
'select user_id,user_passwd,user_logined from user_login where user_id = 'aa\'' AND user_passwd = 'AAAA''; 这样不行
你的是第二种?
输入 aa'就上一第一条sql语句,出错
如果我输入aa",就出第二条sql语句,不出错。
同样都是转换了,第一个单引号转换了没有效果!
'select user_id,user_passwd,user_logined from user_login where user_id = "aa" AND user_passwd = "AAAA"'
if ( $str == '' ) Return False; if ( !$this->connect() ) Return False; /*------- 新查询,释放前次的查询结果 -------*/
if ( $this->QueryID ) {
$this->free();
}
$str = str_replace(""", "\"", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("&", "&", $str);
$this->QueryStr = $str; if ( $this->Debug ) printf("调试: 语句 = %s<br>\n", $this->QueryStr); $this->QueryID = @odbc_exec($this->LinkID, $this->QueryStr);
$this->Row = 0;
if ( !$this->QueryID ) {
$this->halt("错误查询:".$this->QueryStr);
Return False;
} else {
Return $this->QueryID;
}
}
如果输用数据库保留字做字段名则需要用 [] 括起,而不是 ``如果你只使用 mssql2005 ,可令 php.ini 中的 magic_quotes_sybase = On
而使用 addslashes 做转义处理
if ( '' != $tmplBlock ) {
$tmplListArray = getLoopTmplArray($tmplBlock,$tmplPath);
$tmplBlock = '';
$tmplListContent = '';
}$tmplListTemp = AddSlashes($tmplListArray[$eval]);
eval( "\$tmplListTemp = \"$tmplListTemp\";" );
if ( "" == $evalName ) {
$tmplListContentName = "tmplListContent";
} else {
$tmplListContentName = $evalName;
}if ( 0 == $eval ) {
$$tmplListContentName = StripSlashes($tmplListTemp);
} else {
$$tmplListContentName .= StripSlashes($tmplListTemp);
}?>
sql不出错,我这个给摸板赋值的页面就出错了,是不是需要在那里再转回来?
你在模板里使用了 AddSlashes 函数?
那么你就不能 magic_quotes_sybase = On 了
只能在构造 sql 串时: $str = str_replace("'", "''", $str);
修改摸板文件好点还是其他
我是不是在这里修改一下就好了,这样我就不需要修改sql串了?define('MAGIC_QUOTES', get_magic_quotes_gpc());
define('NOW_TIME', time());
define('REMOTE_IP', getenv("REMOTE_ADDR"));#=====================================================
# GPC
#-----------------------------------------------------
Function execSpecialcharsG (&$fArr) {
if ( is_array($fArr) ) {
foreach ( $fArr AS $_arrykey => $_arryval ) {
if ( is_string($_arryval) ) {
$fArr[$_arrykey] = specialCharsG($_arryval);
} else if ( is_array($_arryval) ) {
$fArr[$_arrykey] = execSpecialcharsG($_arryval);
}
}
}
Return $fArr;
}
Function specialCharsG ($fStr) {
$fStr = trim($fStr);
if ( !MAGIC_QUOTES ) {
$fStr = addslashes($fStr);
}
$fStr = htmlspecialchars($fStr);
$fStr = str_replace('javascript', 'javascript ', $fStr);
Return $fStr;
}error_reporting(7);
ob_start();define('PHP_SCRIPT', basename(getenv("SCRIPT_NAME")));
define('INCLUDE_PATH', FILE_PATH."include/");$_GET = execSpecialcharsG($_GET);
$_POST = execSpecialcharsG($_POST);
$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);
$fStr = trim($fStr);
if ( !MAGIC_QUOTES ) {
$fStr = str_replace("'", "''", $fStr);
$fStr = str_replace(""", "\"", $fStr);
$fStr = str_replace("<", "<", $fStr);
$fStr = str_replace(">", ">", $fStr);
$fStr = str_replace("&", "&", $fStr);
$fStr = str_replace("javascript ", "javascript", $fStr);
$fStr = str_replace("\n", "
", $fStr);
$fStr = StripSlashes($fStr); //$fStr = addslashes($fStr);
}
$fStr = htmlspecialchars($fStr);
$fStr = str_replace('javascript', 'javascript ', $fStr);
Return $fStr;
}