[新人求教]向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?> lamp的论坛程序实现像CSDN论坛分页一样的分页效果该怎么写? 请做过大型PHP网站的高手赐教! 请问有没有js弹窗不被拦截的代码?form的方式也试过了还是被拦截 交流贴 大家能说说提高php执行效率和数据库查询效率的经验吗? 状态栏? php_curl.dll php_ldap.dll php_openssl.dll找不到指定的模块??? 关于SESSION的问题 请各位大虾提供一些关于开发“语音聊天室”的资料,谢谢! php非常诡异的抓取网页问题,亟待高手解决,在线等 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?>