首页 > 编程技术 > php

Warning: session_start() [function.session-start]: open_basedir restriction in effect. File解决方法

发布时间:2016-11-25 17:40

Warning: session_start() [function.session-start]: open_basedir restriction in effect. File解决方法

Warning: include() [function.include]: open_basedir restriction in effect. File(/www/webpublic_html/admin/inc/inc.php教程) is not within the allowed path(s): (/www/webpublic_html/searchhight:/tmp) in /www/webpublic_html/searchhight/index.php on line 2

Warning: include(/www/webpublic_html/admin/inc/inc.php) [function.include]: failed to open stream: Operation not permitted in /www/webpublic_html/searchhight/index.php on line 2

Warning: include() [function.include]: Failed opening '/www/webpublic_html/admin/inc/inc.php' for inclusion (include_path='.:/www/wdlinux/php-5.2.17/lib/php') in /www/webpublic_html/searchhight/index.php on line 2

Fatal error: Class 'Db' not found in /www/webpublic_html/searchhight/index.php on line 3


Fatal error : session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in E:footloginlogin.php on line 4

开启了session_start()后出现了这个问题。
php.ini 的open_basedir中加入C:WINDOWSTEMP

,修改.ini文件是很容易出错的。因为该配置文件不是仅仅服务一个程序,所以修改配置文件,带来的后果

可能有很大的影响。通过

ini_set ( 'session.save_path' , dirname ( __FILE__ ) . '/../dirname/' ) ;

php教程 字符串编码转换的常用几种方法

mb_convert_encoding()
PHP的内码转换函数
版本(PHP 4 >= 4.0.6, PHP 5)
这个函数可以将各种编码互相转换

做一个GBK To UTF-8
< ?php
header("content-Type: text/html; charset=Utf-8");
echo mb_convert_encoding("你是我的友仔", "UTF-8", "GBK");
?>

再来个GB2312 To Big5
< ?php
header("content-Type: text/html; charset=big5");
echo mb_convert_encoding("你是我的朋友", "big5", "GB2312");
?>


iconv()
php内码转换函数,同上
因为iconv()在转换gb2312时的bug,所以要这样处理

PHP codeiconv( "UTF-8", "gb2312//IGNORE" , $str)

ignore的意思是忽略转换时的错误,发现iconv在转换字符"—"到gb2312时会出错,如果没有

ignore参数,所有该字符后面的字符串都无法被保存。
另外mb_convert_encoding没有这个bug,所以最好的写法是:
PHP codemb_convert_encoding($str,"gb2312", "UTF-8");

但是需要先enable mbstring 扩展库。
也可以把mysql教程数据库教程的collation设成utf-8就不用作转换了
三句mysql真言
SQL code
SET NAMES utf8;
SET CHARACTER SET utf8;
SET COLLATION_CONNECTION='utf8_general_ci';


自定函数1
--------------------------------------------------------------------------------

---
网上找的转换函数,将GB2312进行转换的,修改为utf-8后转换错误,无法解析中文.....期待正

则狂人...
PHP code<?php
function escape($str) {
         preg_match_all("/[x80-xff].|[x01-x7f]+/",$str,$r);
        $ar = $r[0];
        foreach($ar as $k=>$v) {
                 if(ord($v[0]) < 128)
                            $ar[$k] = rawurlencode($v);
                 else
                            $ar[$k] = "%u".bin2hex(iconv("GB2312","UCS-2",$v));
                                                     }
        return join("",$ar);
}

function unescape($str) {
       $str = rawurldecode($str);
       preg_match_all("/(?:%u.{4})|.+/",$str,$r);
       $ar = $r[0];
       foreach($ar as $k=>$v) {
                if(substr($v,0,2) == "%u" && strlen($v) == 6)
                $ar[$k] = iconv("UCS-2","GB2312",pack("H4",substr($v,-4)));
                  }
       return join("",$ar);
}
?>


自定函数2
--------------------------------------------------------------------------------

---
感谢论坛gingzai777 ,高手就是不一样,一眼就能看出问题所在.....
以后php过滤用这个行了,不需要顾虑文件编码了.....
PHP code<?php
function addslashes_str($str){
$str=addslashes($str);
$str=str_replace($str,";",';');
return $str;
}
function strips教程lashes_str($str){
$str=stripslashes($str);
$str=str_replace($str,';',";");
return $str;
}
?>

设置php教程.ini 脚本超时方法

设置有二种
方法一,在php.ini里面设置

max_execution_time = 1800     ;

当前上面方法可以利用ini_set("选项","值"),
ini_set(''max_execution_time'', ''180'');

方法二 利用php页面中加

set_time_limit(),

如在php文档开始处加上set_time_limit(100),代表为100秒超时哦。

apache服务器解决url中文无法正常显示解决办法
我们在php教程中用个url 编码函数,利用它就可以解决了,方法下如。

<?php
$interest = "arts";
$homepage = "http://www.111cn.net";
$query = "homepage=".urlencode( $homepage );
$query .= "&interest=".urlencode( $interest );
echo $query;
?>
 

解决中文乱码解决方法有很多种,一种是对url编码如urlencode方法,另一种是下面的header头处理方法以binary方法。

<?php教程
$file_name = urlencode($_REQUEST['filename']);
header("Pragma: public"); header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header("Content-Transfer-Encoding: binary");
header('Content-Disposition: attachment; filename='.$file_name);
echo strips教程lashes($_REQUEST['content']);
?>
标签:[!--infotagslink--]

您可能感兴趣的文章: