首页 > 编程技术 > php

个人空间上安装phpMyAdmin方法

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

个人空间上安装php教程myadmin方法

当然你有mysql教程数据库教程。 首先 下载 一份最新版的phpmyadmin mysql管理器。 解压后得到一个phpmyadmin的目录(你可以改名) 找到目录里的config.inc.php文件,打开 找到 $cfg['pmaabsoluteuri'] 修改你将

当然你有mysql数据库。
首先下载一份最新版的phpmyadmin mysql管理器。

解压后得到一个phpmyadmin的目录(你可以改名)

找到目录里的config.inc.php文件,打开
找到 $cfg['pmaabsoluteuri']
修改你将上传到空间的phpmyadmin的网址
如:$cfg['pmaabsoluteuri'] = 'http://www.xxx.com/phpmyadmin/';

还有下面的
$cfg['servers'][$i]['host'] = 'localhost';(通常用默认,也有例外)

$cfg['servers'][$i]['auth_type'] = 'config'; // authentication method (config, http or cookie based)?
在自己的机子里调试用config,如果在网上用cookie。

$cfg['servers'][$i]['user'] = 'root'; // mysql user(用户名,自己机里用root,在网上设你的ftp用户名)
$cfg['servers'][$i]['password'] = ''; // mysql password (ftp密码 自己机里不用设)

$cfg['servers'][$i]['only_db'] = ''; // if set to a db-name, only(你只有一个数据就设置一下)

还有设
$cfg['defaultlang'] = 'zh';
$cfg['blowfish_secret'] = '',输入mysql密码即可。此为绝密的短语密码
设置完毕可以上传到网上了
 

php教程 require/include顺序详解

在大型的web项目中, include_path是一个模块化设计的根本中的根本(当然,现在也有很多基于autoload的设计, 这个不影响本文的探讨), 但是正是因为include_path, 经常会让我们遇到一些因为没有找到正确的文件而导致的看似”诡异”的问题.也就有了如下的疑问:include_path是怎么起作用的?如果有多个include_path顺序是怎么样的?什么情况下include_path不起作用?今天, 我就全面的介绍下这个问题, 先从一个例子开始吧.如下的目录结构:  root     1.php              3.php                     subdir                             2.php                                  3.php在1.php中:
复制代码 代码如下:
<?php
ini_set("include_path", ".:path_to_subdir");
require("2.php");
?>而在2.php中:
复制代码 代码如下:
<?php
require("3.php");
?>而在root目录下的3.php打印出”root”, 在subdir目录下的3.php打印出”subdir”;现在, 我的问题来了:
1. 当在root目录下运行1.php, 会得到什么输出?
2. 在subdir下运行上一级目录的1.php, 有会得到什么输出?
3. 当取消include_path中的当前目录path(也就是include_path=”path_to_subdir”), 上面俩个问题又会是什么输出?
php中的include_path
php在遇到require(_once)/include(_once)的指令的时候, 首先会做如下的判断:
复制代码 代码如下:
要包含的文件路径是绝对路径么?
如果是, 则直接包含, 并结束.
如果不是, 进入另外的逻辑(经过多次调用, 宏展开后进入_php_stream_fopen_with_path)寻找此文件接下来, 在_php_stream_fopen_with_path中, 会做如下判断:
复制代码 代码如下:
要包含的文件路径是相对路径么(形如./file, ../dir/file, 以下用"目录相对路径代替")?
如果是, 则跳过include_path的作用逻辑, 直接解析相对路径(随后单独介绍)会根据include_path,和当前执行文件的path组成一个待选的目录列表, 比如对于文章前面的例子来说, 会形成一个如下的待选列表
复制代码 代码如下:
".:path_to_subdir:current_script_dir然后, 依次从待选列表头部开始, 根据default_dir_separator(本文的环境是”:”)取出待选列表中的一个路径, 然后把要包含的文件名附加在这个路径后面, 进行尝试. 如果成功包含, 则返回, 否则继续下一个待选路径.
到现在为止, 我们已经可以回答我开头提出的3个问题了.
1. 因为在root目录下执行, 所以在1.php中包含2.php的时候, include_path的第二个待选路径起了作用(path_to_subdir), 找到了path_to_subdir/2.php, 而在2.php包含3.php的时候, 当前工作目录是root下, 所以在包含3.php的时候, include_path的第一个待选路径”.”(当前工作目录)下就找到的匹配的文件, 所以得到的输出是”root”.
2. 同1, 只不过当前的路径是subdir, 所以得到的输出是”subdir”.
3. 因为没有了当前路径为include_path, 所以在root目录下运行的时候2.php中包含3.php的时候, 是path_to_subdir起了作用, 所以无论在root还是subdir都将得到”subdir”的输出.
而如果在2.php中清空include_path,
复制代码 代码如下:
<?php
ini_set("include_path", '');
require("3.php");
?>那么将会是current_script_dir起作用, 而这个时候current_script_dir是2.php的路径, 所以还是会得到”subdir”的输出.
目录相对路径
在使用目录相对路径的情况下, 相对路径的基点, 永远都是当前工作目录.
为了说明在目录相对路径下的情况,我们再看个列子, 还是上面的目录结构, 只不过1.php变成了:
复制代码 代码如下:
<?php
ini_set("include_path", "/");
require("./subdir/2.php");
?>2.php变成了:
复制代码 代码如下:
<?php
require("./3.php");
?>如果在root目录下执行, 2.php中寻找3.php将会在当前目录的相对路径下寻找, 所以得到的输出是”root”, 而如果是在subdir下执行上一级目录的1.php(php -f ../1.php), 将会因为在subdir下找不到”./subdir/2.php”而异常退出.
后记
1. 因为使用include_path和相对路径的情况下, 性能会和寻找的次数有关, 最坏的情况下, 如果你有10个include_path, 那么最多可能会重试11次才能找到要包含的文件, 所以, 在能使用绝对路径的情况下最好使用绝对路径.
2. 因为目录相对路径的basedir, 永远都是当前工作路径, 如果要使用, 需要和实际部署路径相关, 所以实际使用的很少(当然, 也有借助chdir来完成的模块).
3. 在模块化的系统设计中, 一般应该在模块内, 通过获取模块的部署路径(dirname(__file__), php5.3以后更是提供了__dir__常量)从而使用绝对路径.

解决编码为gb2312页面ajax交互汉字乱码问题
ajax只支持utf-8格式,不能支持gb2312编码格式,所以经常遇到gb2312的编码的程序使用ajax就出现乱码,刚找到一种解决方案是:

服务器端传送的数据仍是gb2312编码,客户端用js将汉字转变成utf8编码显示在页面

search.php教程
<?php
header("content-type: text/html; charset=gb2312");
include './search.htm';
?>

search.htm
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>高级搜索</title>
</head>
<body>
<h3>高级搜索</h3>
<form method="post" action="">
  学校类型:
  <select name="schooltype">
    <option value="">全部</option>
    <option value="1">小学</option>
    <option value="2">初中</option>
  </select>
  学校名称:
  <select name="sid" id="sid">
    <option value="">请选择学校</option>
  </select>
</form>
<script type="text/网页特效">
function ajax(settings) {
    var xhr = window.activexobject ? new activexobject("microsoft.xmlhttp") : new xmlhttprequest(), successed = false;
    xhr.open(settings.type, settings.url);
    if(settings.type == 'post')
     xhr.setrequestheader('content-type', 'application/x-www-form-urlencoded');
    xhr.send((!settings.cache ? 'time=' + new date().gettime() + '&' : '') + settings.data);
    settings.loader();
    settimeout(function() {
        if(!successed) {
            alert('resquest timeout!');
            xhr.abort();
        }
    }, settings.timeout);
    xhr.onreadystatechange = function() {
        if (xhr.readystate == 4 && xhr.status == 200) {
            settings.callback(xhr.responsetext.replace(/(^s*)|(s*$)/g, ""));
        }
        successed = true;
    }
}
function a(t) {
ajax({
  type: 'post',
  url: 'ajax.php',
  data: 'schooltype=' + t,
  timeout: 8000,
  cache: true,
  loader: function() {},
  callback: function(d) {
   var arr = eval(d);
   if(typeof(arr) == 'object') {
    var obj, option;
    document.getelementbyid('sid').innerhtml = '';
    for(var i = 0; obj = arr; i ++) {
     option = document.createelement('option');
     option.value = obj[0];
     option.innerhtml = txt2utf8(obj[1], '&#');
     document.getelementbyid('sid').appendchild(option);
    }
   }
  }
})
}
function txt2utf8(string, prefix){
    for(var i=0,utf8=[];i<string.length;utf8.push((prefix||'u')+string.charcodeat(i++)));
    return utf8.join('');
}
a(0);
</script>
</body>
</html>

ajax.php

<?php
header("content-type: text/html; charset=gb2312");
$schooltype = !empty($_post['schooltype']) ? $_post['schooltype'] : 0;
switch($schooltype) {
    case 0:
        echo "[['40', '太平溪镇花栗包完全小学'],['41', '太平溪镇长岭黑龙江希望小学'],['42', '乐天溪镇初级中学'],['43', '乐天溪镇莲沱初级中学']]";
        break;
    case 1:
        echo "[['40', '太平溪镇花栗包完全小学'],['41', '太平溪镇长岭黑龙江希望小学']]";
        break;
    case 2:
        echo "[['42', '乐天溪镇初级中学'],['43', '乐天溪镇莲沱初级中学']]";
        break;
    default:
        break;
}
?>

empty,isset,is_null  这几个函数时候,遇到一些问题。甚至给自己的程序带来一些安全隐患的bug。很多时候,对于isset,empty都认为差不多。因此开发时候,就没有注意,一段作为流程判断时候,就出现bug问题了。

 一、举例说明

a.一个变量没有定义,我们该怎么样去判断呢?

 

view source
print?
01 <?php
02 #不存在$test 变量
03   
04 $isset= isset($test)?"test is define!":"test is undefine!";
05 echo "isset:$issetrn";
06   
07 $empty=!empty($test)?"test is define!":"test is undefine!";
08 echo "empty:$emptyrn";
09   
10 $is_null=is_null($test)?"test is define!":"test is undefine!";
11 echo "is_null:$is_nullrn";

 

测试结果是:

image

结果出来了:empty,isset首先都会检查变量是否存在,然后对变量值进行检测。而is_null 只是直接检查变量值,是否为null,因此如果变量未定义就会出现错误!

delphi 枚举设备使用代码

现在的 delphi(2010、xe) 已经自带了 directx 的相关单元(...sourcertlwin).
--------------------------------------------------------------------------------

//枚举函数
function directsoundenumerate(
  lpdsenumcallback: tdsenumcallback; //回调函数
  lpcontext: pointer                 //用户指针
): hresult; stdcall; //返回错误代码, 成功则返回 s_ok(0)

//directsoundenumerate 需要的回调函数的原形:
tdsenumcallback = function(
  lpguid: pguid;            //设备的 guid
  lpcstrdescription: pchar; //设备描述
  lpcstrmodule: pchar;      //模块标识
  lpcontext: pointer        //由 directsoundenumerate 提供的用户指针
): bool; stdcall; //返回 true 表示要继续枚举, 不在继续找了就返回 false

--------------------------------------------------------------------------------

这是常见的代码:
--------------------------------------------------------------------------------
 
unit unit1;

interface

uses
  windows, messages, sysutils, variants, classes, graphics, controls, forms,
  dialogs, stdctrls;

type
  tform1 = class(tform)
    listbox1: tlistbox; //只在窗体上放了一个列表框
    procedure formcreate(sender: tobject);
  end;

var
  form1: tform1;

implementation

{$r *.dfm}

uses directsound; //!

function enumcallback(lpguid: pguid; lpcstrdescription, lpcstrmodule: pchar;
    lpcontext: pointer): bool; stdcall;
begin
  form1.listbox1.items.add(lpcstrdescription);
  result := true;
end;

procedure tform1.formcreate(sender: tobject);
begin
  directsoundenumerate(enumcallback, nil);
end;

end.

--------------------------------------------------------------------------------

在回调函数中直接使用窗体控件不好, 修改如下:
--------------------------------------------------------------------------------
 
uses directsound;

function enumcallback(lpguid: pguid; lpcstrdescription, lpcstrmodule: pchar;
    lpcontext: pointer): bool; stdcall;
begin
  tstrings(lpcontext).add(lpcstrdescription);
  result := true;
end;

procedure tform1.formcreate(sender: tobject);
begin
  directsoundenumerate(enumcallback, listbox1.items);
end;

--------------------------------------------------------------------------------

获取更多信息:
--------------------------------------------------------------------------------
 
uses directsound;

function enumcallback(lpguid: pguid; lpcstrdescription, lpcstrmodule: pchar;
    lpcontext: pointer): bool; stdcall;
begin
  if lpguid <> nil then tstrings(lpcontext).add(guidtostring(lpguid^));
  tstrings(lpcontext).add(lpcstrdescription);
  if lpcstrmodule <> nil then tstrings(lpcontext).add(lpcstrmodule);
  tstrings(lpcontext).add(emptystr);
  result := true;
end;

procedure tform1.formcreate(sender: tobject);
begin
  directsoundenumerate(enumcallback, listbox1.items);
end;

标签:[!--infotagslink--]