热门关键字:  PHP  Cisco  seo  网络广告 虚拟主机 中文域名
当前位置 :| 主页>编程开发>PHP>常见问题>

PHP,MYSQL常见问题与解答

来源:搜站长搜集 作者:未知 时间:2005-12-05 点击:

===> register_globals[全局变量]的相关说明
很多入门的朋友被全局变量搞的很糊涂,可以参考以下的说明:

CODE
  1. 决定是否将 EGPCS(Environment,GET,POST,Cookie,Server)变量注册为全局变量。例如,如果 register_globals = on,那么 URL http://www.example.com/test.php?id=3 将产生 $id。或者从 $_SERVER['DOCUMENT_ROOT'] 得来 $DOCUMENT_ROOT。如果不想用户数据把全局域弄乱的话可以将此选项关闭。自 PHP 4.2.0 开始,本指令默认为 off。推荐使用 PHP 的预定义变量来替代,例如超全局变量:$_ENV,$_GET,$_POST,$_COOKIE 和 $_SERVER。



===> 一个写文本数据的函数,可以有效防止清零
自己用在计数器中,在linux下日ip8万没有发现清零的现象

CODE
  1. // Write Something to a Text
  2. function writetofile($filename,$data,$method="rb+"){
  3.   touch($filename);
  4.   $handle=fopen($filename,$method);
  5.   flock($handle,LOCK_EX);
  6.   $fettle=fwrite($handle,$data);
  7.   if($method=="rb+"){ftruncate($handle,strlen($data));}
  8.   fclose($handle);
  9.   return $fettle;
  10. }
  11. //test
  12. writetofile("test.txt","Some data!");
  13. ?>



===> Client does not support authentication protocol
好多朋友升级了mysql为4.10以上会发生此错误,php4.x下phpmyadmin之类的程序连接不上数据库,是因为mysql4.10以上改变了用户密码验证协议,php的连接模块也需要更换新的,php5默认就是这种新的连接模块...

不想更换可以这样:

CODE
  1. # SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
  2. # FLUSH PRIVILEGES;



官方说明文档:

CODE
  1. Client does not support authentication protocol
  2. MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. If you upgrade the server to 4.1, attempts to connect to it with an older client may fail with the following message:
  3. shell> mysql
  4. Client does not support authentication protocol requested
  5. by server; consider upgrading MySQL client
  6. To solve this problem, you should use one of the following approaches:
  7. Upgrade all client programs to use a 4.1.1 or newer client library.
  8. When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password.
  9. Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function:
  10. mysql> SET PASSWORD FOR
  11.    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');
  12. Alternatively, use UPDATE and FLUSH PRIVILEGES:
  13. mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
  14.    -> WHERE Host = 'some_host' AND User = 'some_user';
  15. mysql> FLUSH PRIVILEGES;
  16. Substitute the password you want to use for ``newpwd'' in the preceding examples. MySQL cannot tell you what the original password was, so you'll need to pick a new one.
  17. Tell the server to use the older password hashing algorithm:
  18. Start mysqld with the --old-passwords option.
  19. Assign an old-format password to each account that has had its password updated to the longer 4.1 format. You can identify these accounts with the following query:
  20. mysql> SELECT Host, User, Password FROM mysql.user
  21.    -> WHERE LENGTH(Password) > 16;
  22. For each account record displayed by the query, use the Host and User values and assign a password using the OLD_PASSWORD() function and either SET PASSWORD or UPDATE, as described earlier.




最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
赞助商连接