<?php
header('ontent-Type:text/html;charset=gb2312');
//创建Access的链接
$conn = new com("ADODB.Connection");
$connstr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=olddatabases.mdb";
$conn->Open($connstr);
//创建Access的数据集
$rs = new COM("ADODB.RecordSet");
$rs->Open("select * from Article where cid ='224'",$conn,1,3);
//Mysql数据库信息
$dbhost ="localhost";
$dbuser ="root";
$dbpassword = "www.hfyefan.com";
$dbname = "hfyefan";
mysql_connect($dbhost,$dbuser,$dbpassword) or die("error!");
mysql_select_db($dbname);
while(!$rs->eof){
//获取Access数据库数据
$title = $rs->Fields("title");
$content = $rs->Fields("content");
$time = time();
//插入文章数据
$sql = "insert into hfyefan_article(tid,sid,isshow,title,addtime,hits,orders,mrank,mgold,description,user,usertype) values(41,0,1,'$title',".$time.",183,0,0,0,'$title','admin',0)";
mysql_query("set names 'gbk' ");
$result=mysql_query($sql);
//获取刚刚插入的数据的ID
$sql1="Select LAST_Insert_ID()";
$result1=mysql_query($sql1);
$rows=mysql_fetch_row($result1);
$lastid = $rows[0];
//打印ID
echo $lastid;
echo "<br/>";
//插入文章内容
$sql2 = "insert into hfyefan_article_field(aid,body) values($lastid,'$content')";
mysql_query("set names 'gbk' ");
$result2=mysql_query($sql2);
//将记录集指针下移
$rs->Movenext();
}
?>
如果有其他问题,联系qq:446881654
注意:mysql_query("set names 'gbk' ");中文写数据库的时候需要这个