Archive for the ‘PHP’ Category

kohana3中的随机查询

Wednesday, January 5th, 2011
ORM的

ORM::factory('some_model')->order_by(DB::expr('RAND()'))->find();

Model的

$this->db->from('table')->select('*')->limit(1)->orderby(null, 'RAND()')->get();

phpMyAdmin-2.8.2安装

Monday, July 31st, 2006

网上常见的 phpMyAdmin安装文章都是老版本的.

phpMyAdmin-2.8.2的配置文件在

phpMyAdmin\libraries\config.default.php.

先设置phpMyAdmin的位置

$cfg['PmaAbsoluteUri'] = ‘http://localhost/phpmyadmin/’;

CTRL+G到71行设置用户名和密码

$cfg['Servers'][$i]['auth_type']     = ‘config’;    // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user']          = ‘jondy’;      // MySQL user
$cfg['Servers'][$i]['password']      = ‘zhack.com’;          // MySQL password (only needed

设置中文支持

$cfg['DefaultLang'] = ‘zh-gb2312′;

$cfg['DefaultCharset'] = ‘gb2312′;

这样就可以使用了,为了安全要设置$cfg['Servers'][$i]['auth_type']

为http或cookie哦,这样登陆phpMyAdmin时就要身份验证了.

用户名和密码和连接MySQL的一样.

最好将phpMyAdmin目录改个别的名比如love_jondy,

毕竟这么牛X的程序不一定哪天出个漏洞什么的,安全第一呀,呵呵.

我的一个客户用的51.net的虚拟主机,安装的时候提示

Warning: unknown encoding “gb2312″ in /z2/xxxxxxx/public_html/love_jondy/libraries/string.lib.php on line 41

简单的处理方法是编辑libraries/string.lib.php

CTRL+G到41行,在前边加上//注释掉,哈哈,管他什么if else呢.

PHP无法取得表单提交的数据问题

Tuesday, July 25th, 2006

首先运行
<?
phpinfo();
?>
查看你的php环境是否配置好。
如果配置好了,查看你的php的配置文件php.ini文件中
register_globals = off 还是 on
如果是off 你应该这样访问post or get的数据 $HTTP_POST_VARS['var'] $HTTP_GET_VARS['var']
如果改成on
你可以直接访问,例如:
$name 就不需要$HTTP_POST_VARS['name']了

Apache+PHP+MySQL环境搭建笔记

Sunday, July 16th, 2006

安装apache1.3.31

傻瓜试安装,一路下一步,安装路径选个C:\

添主机时添localhost

安装php-4.4.2-Win32

释放压缩包内容到apache目录

复制php4ts.dll  php4apache.dll到apache\bin

将php.ini-recommended复制到apache\bin并改名为php.ini

编辑php.ini

display_errors = On

extension_dir = “C:\Apache\php-4.4.2\extensions”

upload_tmp_dir = upload_tmp_dir = C:\Apache\tmp

session.save_path = C:\Apache\tmp

session.use_trans_sid = 1
在客户不支持cookie的时候,session_id可以附在QUERY_STRING后边
,如:abcd.php?a=c&b=d&PHPSESSID=saadafsf24235346asdfsda

编辑httpd.conf

以模块方式运行PHP
在httpd.conf后边加

LoadModule php4_module bin/php4apache.dll
AddType application/x-httpd-php .php .phtml

以 CGI 模式运行PHP
ScriptAlias /php/ “c:/apache/php-4.4.2/”
AddType application/x-httpd-php .php
Action application/x-httpd-php “/php-4.4.2/php.exe”

索引文件
<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.php index.cgi index.pl
</IfModule>

mysql-4.0.17-nt安装时运行我的那个BAT就OK了