Home > php教程 > php手册 > body text

php 单引号处理 解决数据插入错误

WBOY
Release: 2016-06-06 20:10:52
Original
1725 people have browsed it

php 单引号处理 解决数据插入错误解决方案对于PHP中[magic_quotes_gpc],没有开启,如何解决数据写入问题,右侧源代码,解决网站SQL注入漏洞function escape($str){if(function_exists('mysql_escape_string')){$str = mysql_escape_string($str);} elseif

php 单引号处理 解决数据插入错误   解决方案 对于PHP中[magic_quotes_gpc],没有开启,如何解决数据写入问题,右侧源代码,解决网站SQL注入漏洞   function escape($str){  if(function_exists('mysql_escape_string')){  $str = mysql_escape_string($str);  } elseif (function_exists('mysql_real_escape_string')){  $str = mysql_real_escape_string($str);  } elseif (!get_magic_quotes_gpc()){  $str = addslashes($str);  }  return $str; } 举例: 对于表单提交的数据,$_POST,进行循环处理,如下,   foreach($_POST as $key=>$value){       $_POST[$key]=escape(trim($value));  }
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template