<?php $server ="(local)"; //服务器IP地址,如果是本地,可以写成localhost $uid ="sa"; //用户名 $pwd ="123456"; //密码 $database ="ABC"; //ms数据库名称 //进行my数据库连接 $conn =mssql_connect($server,$uid,$pwd) or die ("connect failed"); mssql_select_db($database,$conn); $con = mysql_connect("192.168.1.108","root","123456"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("openfile", $con); $result = mysql_query("SELECT * FROM ofgroupuser"); while($row = mysql_fetch_array($result)) { // //$haha=mssql_query($query123); foreach ($row as $key => $value) { $query123 ="INSERT INTO bbb (ccc) VALUES ('".$row['username']."')"; $haha=mssql_query($query123); } //print_r ($row); //echo "<br>"; //echo $row['groupName']."<br>"; //echo $row['username']."<br>"; } echo 1111; echo "<br>"; //执行查询语句 //$query123 ="INSERT INTO bbb (ccc) VALUES ('王')"; $query ="select * from bbb"; $row =mssql_query($query); //$haha=mssql_query($query123); //打印输出查询结果 while($list=mssql_fetch_array($row)) { print_r($list); echo "<br>"; } ?>
从my到ms 一条数据多插入了五次?。。。。
怀疑循环有问题。。。