首页 > phper

php 导入.sql文件到mysql数据库

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操作类

 代码如下 复制代码 * 1、连接服务器 2、各类sql动作*/class mysql{    private $host;  //服务器地址    private $name;  //用户名称    private $pass;  //密码    private $table; //连接数据库教程    private $jiema; //设置解码&...
阅读全文

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";

阅读全文

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 ";
 }
}

阅读全文

PDO 查询mysql数据库

本文章提供一款由php pdo mysql操作实例教程了,这是由php pdo查询mysql数据并显示  代码如下 复制代码 try {    $dbh = new pdo($beidou_connstr,$beidou_user,$beidou_pass);    foreach ($dbh->query('select count(*) as count1, count(*) as count2 from bd_reve.user_day') as $row) ...
阅读全文

服务器运行状况即时显示表

<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>

阅读全文