set_time_limit(0); //设置超时时间为0,表示一直执行。当php在safe mode模式下无效,此时可能会导致导入超时,此时需要分段导入
$db = new mysql($location['host'],$location['hostname'],$location['hostpass'],$location['table'],"utf8",$location['ztime']);
$fp = @fopen($sql, "r") or die("不能打开sql文件 $sql");//打开文件
while($sql=getnextsql()){
mysql_query($sql);
}
//echo "用户数据导入完成!";
fclose($fp) or die("can't close file $file_name");//关闭文件
简单的MYsql操作类
mysql 分页类(带分页条功能)
php excel导入mysql
require_once './includes/reader.php';
// excelfile($filename, $encoding);
$data = new spreadsheet_excel_reader();
// set output encoding.
$data->setoutputencoding('gbk');
//"data.xls"是指要导入到mysql中(的)excel文件
$data->read('date.xls');
@ $db = mysql_connect('localhost', 'root', '1234') or
die("could not connect to database.");//连接数据库
mysql_query("set names 'gbk'");//输出中文
mysql_select_db('wenhuaedu'); //选择数据库
error_reporting(e_all ^ e_notice);
for ($i = 1; $i <= $data->sheets[0]['numrows']; $i++) {
//以下注释(的)for循环打印excel表数据
for ($j = 1; $j <= $data->sheets[0]['numcols']; $j++) {
echo $data->sheets[0]['cells'][$i][$j].",";
}
echo "n";
电话号码正则表达式
//js 电话号码正则表达式
php 查找数组键名并输出值
$q ='www.phprm.com';
$items = array(
"great <em>bittern</em>"=>"botaurus stellaris",
"little <em>grebe</em>"=>"tachybaptus ruficollis",
"black-necked grebe"=>"podiceps教程 nigricollis",
"little bittern"=>"ixobrychus minutus",
"black-crowned night heron"=>"http://www.phprm.com",
"www.phprm.com"=>"ardea purpurea",
"white stork"=>"ciconia ciconia",
"spoonbill"=>"platalea leucorodia",
"red-crested pochard"=>"netta rufina",
"common eider"=>"somateria mollissima",
"red kite"=>"milvus milvus",
"hen harrier"=>"circus cyaneus",
"heuglin's gull"=>"larus heuglini"
);
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
echo "$key|$value ";
}
}
php 缓存技术实例
$filename = 'cachefile.php';
$str ='echo "bb";';
if( is_file( $filename ) )
{
$tmp = readcache( $filename ) ;
}
else
{
createcache( $filename,$str );
}
PDO 查询mysql数据库
php 截取字符串函数(中文字符串)(1/2)
function mysubstr( $str, $length ){
$tagcnt = 0;
$charcnt = 0;
$tag = '';
$maxlen = strlen( $str );
$resultstr = '';
$tagstack = array();
php 日期正则表达式
//日期实例二
?>
php 判断字符串包含指定字符
//实例一
//实例二
服务器运行状况即时显示表
<html><title)服务器运行状况即时显示表</title>
<table border=0><tr><td bgcolor=litered width=100% colspan="9"><p align="center"><b>服务器运行状况即时显示表</b><center>
<?php教程
set_time_limit(0);
echo strftime ("%y 年 %m 月 %d 日. ");
?>
</td></tr>
<tr><td bgcolor="#cococo">ip 地址</td><td bgcolor="#cococo">检测时间</td>
<td bgcolor="#cococo">ftp </td>
<td bgcolor="#cococo">telnet</td><td bgcolor="#cococo">smtp </td>
<td bgcolor="#cococo">dns</td><td bgcolor="#cococo">http </td>
<td bgcolor="cococo">pop3</td><td bgcolor="#cococo">finger </td>
</td></center>