PHP 5.3.0 连接mysqli出错的解决
近日因公司开发需要,在本机Win7下架设了Apache+MySql+PHP
所使用PHP版本:PHP5.3.0, 之后发现无法连接mysql数据库,均报超时错误:
PHP Warning: mysqli::mysqli(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in xxx.php on line x
PHP Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
in xxx.php on line x
在网站上查找了很久,均没有有效的解决办法.
后来在国外的网上查到此原因与windows的hosts文件有关
对如下进行修改:
# 127.0.0.1 localhost
#:: 1 localhost
修改为
127.0.0.1 localhost
#:: localhost
问题解决
相关文档:
1、过滤标签(HTML):strip_tags()
例如:
<?php
$text = '<?php ?><p>Test paragraph.</p><!-- Comment -
-> <a href=http://topic.csdn.net/u/20090311/09/"#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// 允许使用<p>和<a>
echo stri ......
<?php
$start = ip2long('192.168.1.1');
$start = sprintf("%u", $start) ;
$end = ip2long('192.168.1.50');
$end = sprintf("%u", $end) ;
for ($start; $start<$end; $start++){
echo long2ip($start)."<br>";
}
?> ......
最近一年来一直在使用fedora,发现linux真是太适合我了,喜欢写程序,自己瞎倒腾,唉windows误我大好年华……
用PHP写了一段程序用于提取网页中的数据,相信搜索引擎也是差不多的想法,只不过他们数据多,算法好些,呵呵
[php]
<?php
/*
*此文件的目标是自动搜集存储8684上的深圳市公交数据
*
*由 ......
<?php
header("content-type:image/png");
$img=ImageCreate(100,35);
$bgcolor=ImageColorAllocate($img,0,0,0);
$red=ImageColorAllocate($img,255,0,0);
$bgcolortrans=ImageColorTransparent($img,$bgcolor);
ImageString($img,5,10,10,"PNG PHP",$red);
ImagePng($img);
ImageDestro ......
1.如果一个方法能被静态,那就声明他为静态的,速度可提高1/4;
2.echo的效率高于print,因为echo没有返回值,print返回一个整型;
3.在循环之前设置循环的最大次数,而非在在循环中;
4.销毁变量去释放内存,特别是大的数组;
5.避免使用像__get, __set, __autoload等魔术方法;
6.requiere_once()比较 ......