[新人求教]向SQL写入的文本中含有 英文单引号 怎么写入? $info=$_POST["info"];如上,$info中为提交的表单文本,可能含有英文单引号 '为了能够顺了插入到MySqL中,应该怎么替换呢?谢谢各位前辈~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $info=str_replace("'",'',$info); //替换成空$info=mysql_real_escape_string($info); //将'转义 if (get_magic_quotes_gpc()) { $name = stripslashes($info);}else{ $name = mysql_real_escape_string($info);}防sql注入,也可过滤引号等字符的 直接这个函数不是更好?htmlspecialchars($str);取出来在用这个转换html_entity_decode($str);<?php$orig = "I'll \"walk\" the <b>dog</b> now";$a = htmlentities($orig);$b = html_entity_decode($a);echo $a; // I'll "walk" the <b>dog</b> nowecho $b; // I'll "walk" the <b>dog</b> now// For users prior to PHP 4.3.0 you may do this:function unhtmlentities($string){ // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string); // replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl);}$c = unhtmlentities($a);echo $c; // I'll "walk" the <b>dog</b> now?> 怎樣將sql2000的語句轉成sql2005, 望高手幫忙! 謝謝 请教下载远程图片的问题 怎么触发textarea里文本显示 求指点 每次都要右键,烦死了,求批处理方法执行版本管理。 mysql5到底是用什么字条集来链接的好,“GBK、GB2312、utf8”来着有分。 gb2312的页面调用utf-8的数据会不会出现乱码? 问一个数字格式化问题 如何在MYSQL 表中保存WORD文件呢? 请问这个cookie设置该怎么写? apache安装好了,怎样安装php? 验证码无法显示,高手来解决下
{
$name = stripslashes($info);
}
else
{
$name = mysql_real_escape_string($info);
}防sql注入,也可过滤引号等字符的
htmlspecialchars($str);
取出来在用这个转换
html_entity_decode($str);<?php
$orig = "I'll \"walk\" the <b>dog</b> now";$a = htmlentities($orig);$b = html_entity_decode($a);echo $a; // I'll "walk" the <b>dog</b> nowecho $b; // I'll "walk" the <b>dog</b> now
// For users prior to PHP 4.3.0 you may do this:
function unhtmlentities($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}$c = unhtmlentities($a);echo $c; // I'll "walk" the <b>dog</b> now?>