php 将mssql数据导入到dedecms完整版
<?php
$link = mssql_connect("127.0.0.1", "sa", "sa") or die("Can't connect sql server");
mssql_select_db("cheng", $link) or die("Select database failure");
mysql_connect('localhost', 'root', 'root') or die('mysql服务器不能连接');
mysql_select_db('loupan') or die('error');
mysql_query("set Names 'gb2312'");
$ms_sql = "Select * from sony_z2800";
$ms_query = mssql_query($ms_sql) or die('55555');
$typeid = 23;
$write = '';
$sj = '';
$sjzt = '';
while ($ms_rs = mssql_fetch_array($ms_query)) {
$filetype = $ms_rs[8];
$language = $ms_rs[6];
$os = $ms_rs[10];
$softsize = $ms_rs[7];
$softlinks = mysql_escape_string("{dede:link islocal='1' text='迅雷下载'}" . $ms_rs[11] . "{/dede:link}");
$title = mysql_escape_string(mb_convert_encoding($ms_rs[3], 'gbk', 'gb2312'));
$click = $ms_rs[9];
if (!is_numeric($click)) {
$click = mt_rand(100, 1000);
}
$litpic = mysql_escape_string(str_replace('" />', '', str_replace(' <img src="', '', $ms_rs[12])));
$desciption = "";
$introduce = '';
//die($desciption);
$addsoft = "Insert into 3g_addonsoft(typeid,filetype,language,softtype,accredit,
os,softrank,officialUrl,officialDemo,softsize,softlinks,introduce,templet,userip,redirecturl)";
$addsoft.= " values
('$typeid','$filetype','$language','','','$os','3','','','$softsize','" . $softlinks . "','$introduce','','202.103.69.94','')";
mysql_query($addsoft) or die('addsoft' . $addsoft . mysql_error());
$newid = mysql_insert_id();
$temp_title = $title . '-' . $sj . '-' . $language;
$seo = $os . $sj . $sjzt;
keywords = $os . ',' . $sj . ',' . $sjzt . ',' . $title . ',' . $language$archives = "Insert into 3g_archives
(id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,litpic,writer,source,pubdate,senddate,mid,dutyadmin
,description,keywords)";
$archives.= " values
('$newid','$typeid','0','1255070897','p','1','3','0','$click','0','$temp_title','$litpic','$write','未
知','1255070897','1255070970',1,1,'$desciption','$keywords')";
mysql_query($archives) or die('archives ' . $temp_title . '|' . $archives . mysql_error());
$arctiny = "Insert into 3g_arctiny(id,typeid,typeid2,arcrank,channel,senddate,sortrank,mid) values
($newid,$typeid,0,0,3,'1255070897','1255070970',1)";
mysql_query($arctiny) or die('arctiny' . $arctiny . mysql_error());
}
echo 'success';永久链接:http://www.phprm.com/code/7bc01cb28c8edfd55ccad51e2a85e66d.html
转载随意!带上文章地址吧。