??能否在php中从mysql的一个表中读出数据,然后再插入到sqlserver的一个表中?(在一个php文件中)

huchengyu huchengyu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
急需!!!代码如下:
<?
//dl("php_mssql70.dll");
include "set.php";
$ConnM = mysql_connect("$My_host","$My_user","$My_password");
mysql_select_db("$My_db",$ConnM);

$Query = "select Title,Author,Up_date,Content,FilePath,FileName,hits from Articles";
$Result = mysql_query($Query,$ConnM) or die("Can not open the table");
$i=0;
while($Rows = mysql_fetch_array($Result))
{
$i=$i + 1;
echo $i;
echo "\n";

//往sqlserver中添数据
$Query = "insert into td_Articles (Title,Author,CreatedDate,Content,Url,Clicks) values('";
$Query = $Query.$Rows["Title"]."','";
$Query = $Query.$Rows["Author"]."','";
$Query = $Query.$Rows["Up_date"]."','";
$Query = $Query.$Rows["Content"]."','";
$Query = $Query.$Rows["FilePath"].$Rows["FileName"]."','";
$Query = $Query.$Rows["hits"]."')";
//
$ConnS = mssql_connect("localhost","sa","00000");
mssql_select_db("DotNetNuke",$ConnS);
$Result1 = mssql_query($Query,$ConnS) or die("Can not open the table");
if($Result1)
{
echo "OKKKKKKKK!";
}
else
{
echo "Failllllll!";
}

}
mssql_close($ConnS);

mysql_close($ConnM);

?>
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
huchengyu
基础编程 21,889 成员 140,329 内容