07/03/27 18:34
我用的是php4.4.7 ,phpMyAdmin - 2.10.0.2,mysql 5.2.3
装完后先是无法登陆,网上搜索后用 old_password() 解决成功;
然后又提示 "无法载入 mcrypt 扩展" ,查找文档,得知需要“libmcrypt .dll"支持。php4.4.7 install中无此文件,php5.2中有,COPY到/WINSYSTEM32/中,重起APACHE,搞定!
05/08/26 20:10
Apache和IIS都没法正确加载php_mysql.dll。google了一下,原来发现出现这个问题的人还不少,PHP startup: Unable to load dynamic library :E;\PHP5\ext\php_mysql.dll。明明php_mysql.dll就摆在extension_dir (= "E:/PHP5/ext")下的嘛,怎么会呢?而且就在php_mysql.dll之前的extension=php_gd2.dll都没有出现这个问题,怪了!有人说copy libmysql.dll到 %windir%\system32下就可以解决问题,其实"华山不这一条道":
PHP被我挪了个窝,%ProgramFiles%到E:\下,导致一些要依赖于其他dll才能工作的扩展无法正常加载这些dll,出现加载扩展出
错,以刚才的php_mysql.dll为例,php_mysql依赖libmysql.dll,由于给PHP5挪窝了,而又没有把新的E:\PHP5夹道%PATH%中去
,所以没法找到这个libmysql.dll,才会出错。所以为了能够使用这些mysql的扩展,除了要正确地配置extension_dir外
,还得保证系统能够这些扩展所依赖的dll,解决的办法有两个:
1 将这些依赖的dll拷贝到%windir%\system32下
2 或者将PHP5的安装目录添加到%PATH%中。
无论那个都可以很好地达到我们地目的。
够简单的,但是有时候还就想不到哪儿去。
到底哪些扩展依赖哪些dll呢?以下列表可以帮助我们回答这个问题:
php_curl.dll CURL, Client URL library functions Requires: libeay32.dll, ssleay32.dll (bundled)
php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll
(bundled) PHP >= 4.3.0 requires: iconv.dll (bundled)
php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll,
php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll
php_ingres.dll Ingres II functions Requires: Ingres II libraries
php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled)
php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll(bundled),
PHP >= 4.3.0 requires libeay32.dll,ssleay32.dll (bundled)
php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll (bundled)
php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll (bundled)
php_msql.dll mSQL functions Requires: msql.dll (bundled)
php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll (bundled)
php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysqli.dll (bundled)
php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll (bundled)
php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll, expat.dll (bundled).
PHP >= 4.2.1 requires sablot.dll, expat.dll, iconv.dll (bundled).
05/08/03 00:27
一、输出信息控制函数
这些函数可以让你控制你的脚本输出的内容.可以用于许多不同的情况,特别是在你的脚本已经输出信息后需要发送文件头新的情况. 输出控制函数不对使用 header() 或 setcookie() 发送的文件头信息产生影响,只对那些类似于 echo() 和 PHP 代码的数据块有作用.
例 1. 控制输出
ob_start();
echo "Hellon";
setcookie ("cookiename", "cookiedata");
ob_end_flush();
?>
在上面的例子中,使用 echo() 的输出内容将会保存在输出缓冲区中,直到调用了 ob_end_flush(). 这样做有意义的地方是,调用 setcookie() 的内容被成功的存储在 cookie 里面而不会引起错误. (正常情况下,你不可以在有数据已经发送后再发送文件头信息到用户浏览器.)
相关函数 header() and setcookie().
韩数列表
flush — 刷新输出缓冲区
保存在输出缓冲区的内容会被发送到浏览器
ob_start — 打开输出缓冲区
这样所有的输出信息不在直接发送到浏览器,而是保存在输出缓冲区里面
ob_get_contents — 返回输出缓冲区的内容
如果你想以后处理输出的内容,可以调用这个函数保留一个备份
ob_get_length — 返回输出缓冲区的内容长度
ob_end_flush — 结束(发送)输出缓冲区的内容,关闭输出缓冲区
ob_end_clean — 删除(放弃)输出缓冲区的内容,关闭输出缓冲区
如果你的程序发现输出内容有问题,可以放弃所有输出内容,可以防止泄漏某些秘密信息
ob_implicit_flush — 打开或关闭直接刷新
打开后,每个脚本输出都直接发送到浏览器,不再需要调用 flush()
二、取得当前目录
这是 php4 的新的目录函数!
string getcwd(void)
返回为当前脚本路径的字符串!
三、 解决脚本超时
在 php 的配置/信息里面有一个设置脚本执行时间的函数,具体情况如下:
set_time_limit
配置该页最久执行时间。
语法: void set_time_limit(int seconds);
返回值: 无
函数种类: PHP 系统功能
内容说明
本函数用来配置该页最久执行时间。默认值是 30 秒,在 php.ini 中的 max_execution_time 变量配置,若配置为 0 则不限定最久时间。当执行到该函数时,才开始计算。例如,若默认是 30 秒,而在执行到该函数前已执行了 25 秒,而用本函数改为 20 秒,则该页面最长执行时间为 45 秒。
使用实例:
我的文章搜索函数由于文章数目的增加,经常会产生超时错误,我把脚本执行时间改为200秒后情况大大缓解!
set_time_limit(200);
?>
四、 数组遍历
· foreach
在 PHP4中,新增了一个循环语句 foreach,它很像是 perl和其它的语言,你可以给它一个阵列,让它来取出阵列的值。它有下列这二个语法,第二个语法是较次要的,但是可用来作为第一个语法的延伸。
foreach(array_expression as $value) statement
foreach(array_expression as $key => $value) statement
第一个形式的循环,它会在每个循环上,将目前元素的值分配给 $value,并且向后移动阵列的內部指针,所以在下一个循环的时候,你就会看到下一个元素了。
第二个形式的循环和第一个是相同的,不同的是它会在每个循环将目前元素的索引值分配给变量 $key。
注意 : 当 foreach第一次开始执行的时候,它会把阵列的內部指针重新设定到阵列的第一个元素,意思是说,在使用 foreach之前,你不必再去调用 reset( )。
注意 : foreach的功能是复制,而不是阵列它本身,因此并不会改变阵列指针
下面范例的功能都是相同的 :
reset ($arr);
while (list(, $value) = each ($arr)) {
echo "Value: $value
";
}
foreach ($arr as $value) {
echo "Value: $value
";
}
?>
下面范例的功能也都是相同的 :
reset ($arr);
while (list($key, $value) = each ($arr)) {
echo "Key: $key; Value: $value
";
}
foreach ($arr as $key => $value) {
echo "Key: $key; Value: $value
";
}
?>
以下的范例将说明 foreach的用法 :
/* foreach example 1: value only */
$a = array (1, 2, 3, 17);
foreach ($a as $v) {
print "Current value of $a: $v.
";
}
/* foreach example 2: key and value */
$a = array (
"one" => 1,
"two" => 2,
"three" => 3,
"seventeen" => 17
);
foreach($a as $k => $v) {
print "$a[$k] => $v.
";
}
?>
05/08/03 00:23
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
?>
在php环境运行上面的代码,大家就可以看到浏览器询问用户是否下载excel文档,点击保存,硬盘上就多了一个excel的文件,使用excel打开就会看到最终的结果。
其实在做真正的应用的时候,大家可以将数据从数据库中取出,然后按照每一列数据结束后加\t,每一行数据结束后加\n的方法echo出来,在php的开头用header("Content-type:application/vnd.ms-excel");表示输出的是excel文件,用header("Content-Disposition:filename=test.xls");表示输出的文件名为text.xls。这样就ok了。
我们更可以修改header让他输出更多格式的文件,这样php在处理各种类型文件方面就更加方便了
05/03/01 01:49
修改 inc_presswork.php
查找 function get_archive()
把
$sql = "select distinct FROM_UNIXTIME(regdate, '%Y,%m') from t3_".$dbid." where $is_public order by regdate desc $q_limit";
$result = @mysql_query($sql);
while(list($regdate) = @mysql_fetch_array($result)) {
list ($p_year, $p_month) = split(",", $regdate);
$p_rep = $GLOBALS["skin"]->s_archive_rep;
$p_rep = str_replace("", "index.php?setdate=$p_year".$p_month, $p_rep);
$p_rep = str_replace("", $p_year."年 ".$p_month."月", $p_rep);
$p .= $p_rep;
}改成
$sql = "select distinct FROM_UNIXTIME(regdate, '%Y,%m') from t3_".$dbid." where $is_public order by regdate desc $q_limit";
$sql = "select distinct FROM_UNIXTIME(regdate, '%Y,%m'),count(no) from t3_".$dbid." where $is_public group by FROM_UNIXTIME(regdate, '%Y,%m') order by regdate desc $q_limit";
$result = @mysql_query($sql);
while(list($regdate,$rep_cnt) = @mysql_fetch_array($result)) {
list ($p_year, $p_month) = split(",", $regdate);
$p_rep = $GLOBALS["skin"]->s_archive_rep;
$p_rep = str_replace("", "index.php?setdate=$p_year".$p_month, $p_rep);
$p_rep = str_replace("", $p_year."年 ".$p_month."月", $p_rep);
$p_rep = str_replace("", "(".$rep_cnt.")", $p_rep);
$p .= $p_rep;
}
修改对应皮肤文件夹内的
skin.html
查找
在后面添加