error_reporting(NULL);
header("Content-type: text/html; charset=GBK");
date_default_timezone_set(PRC);
$t1 = microtime(true);
$conn = @ mysql_connect("localhost:3306", "root", "root");// or die("数据库链接错误");
if(!$conn){ //数据库链接错误 写入日志
echo "数据库链接错误".date("Y-m-d h:i:s");
writelog(date("Y-m-d H:i:s")." 数据库链接错误 \r\n");
die;
}
echo "数据库连接成功!<hr/>";
mysql_select_db("bkill", $conn);
mysql_query("set names 'GBK'");
$sql = "select ooxx";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)){
$data[] = $rows;
}
return $data;
$t2 = microtime(true);
$log = " 成功 耗时: ".round($t2-$t1,3)."秒 返回代码: ".$result;
writelog(date("Y-m-d H:i:s").$log."\r\n");
//日志函数
function writelog($content){
file_put_contents("log.txt", $content,FILE_APPEND);
}
//检测url是否可访问
function chkurl($url){
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 10);//设置超时时间
curl_exec($handle);
//检查是否404(网页找不到)
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return false;
}else{
return true;
}
curl_close($handle);
}