易截截图软件、单文件、免安装、纯绿色、仅160KB

php 安全

如何不使用prepared statment,而是用过滤的方法避免SQL注入呢?
一般来说mysql自带的过滤函数是比较可靠的。mysql_real_escape_string()
但是这个函数在某些字符集中有问题,比如GBK。如果你用UTF8那没关系。
在PHP里设置数据库的字符集不应该用:mysql_query("SET NAMES UTF8");
而应该用:mysql_set_charset()
这样mysql_real_escape_string()在处理GBK编码的时候就不会出问题了。
mysql_real_escape_string() not safe when SET NAMES is used
use mysql_set_charset() instead.
Note: This is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended.
SET NAMES is usually used to switch the encoding from what is default to what the application needs. This is done in a way that mysql_real_escape_string doesn’t know about this. This means if you switch to some multi byte encoding that allows backslash as 2nd 3rd 4th… byte you run into trouble, because mysql_real_escape_string doesn’t escape correctly. UTF-8 is safe…
Safe way to change encoding is mysql_set_charset, but that is only available in new PHP versions


相关文档:

blog源码整理:php+mysql博客程序25种

Blog系统作为大家最常接触的互联网东东,在站长群体中几乎人手一博,从知名门户的博客频道,到网络营销专家博客,网民对博客的关注度在不断提高并深化。目前网上免费的blog系统太杂,在此整理PHP版的Blog介绍如下:
1、wordpress:http://www.wordpress.org 功能也很全面,应该是支持blog的首选。它有最强的模版功能,已经 ......

PHP图片处理类


<?php
/*
图片处理函数功能:缩放、剪切、相框、水印、锐化、旋转、翻转、透明度、反色
处理并保存历史记录的思路:当有图片有改动时自动生成一张新图片,命名方式可以考虑在原图片的基础上加上步骤,例如:图片名称+__第几步
*/
class picture{
var $PICTURE_URL;//要处理的图片
var $DEST_URL="temp__01.jpg" ......

PHP数组函数


将一个1维数组分割成2维数组 array_chunk()
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));

比较2个数组,array_diff_assoc()或者array_diff(),如果返回值为空,表示两个数组相同,否则就不同。
用一个函数来过滤数组中的数值array_filter()


functi ......

php与mysql原子操作

 很久都没有写一下学习日志了,都不知道最近在忙什么,突然觉得自己应该写点什么上去.
    数据库的原子操作是两三个月前学的东西了,今天突然又用到了,因此今天必须得将其记录下来,否则下次又要重新搜索了.
    原子操作常用的方法就是通过数据回滚来实现,用 PHP 来实现数据库回滚 ......

PHP smarty学习

php文件
<?php
mysql_connect("localhost","","");
mysql_query("set names 'gb2312'");
mysql_select_db("shop");
$sqlstr="select * from goods";
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;//设置各个目录的路径,这里是安装的重点
$smarty->template_dir ="smarty/templates/templa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号