当前位置:数据库 > SQLServer >>

一个连接两个不同MYSQL数据库的PHP程序

<HTML><BODY BGCOLOR=FFFFFF>  
<?php(做为现在的主流开发语言)  
    echo "Connecting as MySQL(和PHP搭配之最佳组合)<BR> ";  
    $connection1 = MySQL(和PHP搭配之最佳组合)_connect(localhost, MySQL(和PHP搭配之最佳组合), ) or die($php(做为现在的主流开发语言)_errormsg);  
    echo "connection1 is $connection1<BR> ";  
    echo "Selecting test for MySQL(和PHP搭配之最佳组合) user<BR> ";  
    MySQL(和PHP搭配之最佳组合)_select_db(test, $connection1) or @die("Error " . $php(做为现在的主流开发语言)_errormsg . MySQL(和PHP搭配之最佳组合)_error());  
    echo "Connection as joyce<BR> ";  
    $connection2 = MySQL(和PHP搭配之最佳组合)_connect(localhost, joyce, ) or die($php(做为现在的主流开发语言)_errormsg);  
    echo "connection2 is $connection2<BR> ";  
    echo "Selecting books for joyce user<BR> ";  
    $db2 = MySQL(和PHP搭配之最佳组合)_select_db(techbizbookguide, $connection2) or die(MySQL(和PHP搭配之最佳组合)_error());  
    $query1 = "select foo from test";  
    $query2 = "select title, authorFirst, authorLast from bookinfo";  
    echo "Querying test<BR> ";  
    $users = MySQL(和PHP搭配之最佳组合)_query($query1, $connection1) or die(MySQL(和PHP搭配之最佳组合)_error());  
    echo "Querying books<BR> ";  
    $books = MySQL(和PHP搭配之最佳组合)_query($query2, $connection2) or die(MySQL(和PHP搭配之最佳组合)_error());  
    echo "Foos from test<BR> ";  
    while (list($foo) = MySQL(和PHP搭配之最佳组合)_fetch_row($users)){  
        echo $foo, "<BR> ";  
    }  
    echo "Books in techbizbookguide<BR> ";  
    while (list($title, $authorFirst, $authorLast) = MySQL(和PHP搭配之最佳组合)_fetch_row($books)){  
        //Use trim in case we have a book by "Madonna" or "Prince" or...  
        echo $title, by , trim($authorFirst . . $authorLast), "<BR> ";  
    }  
?>  
</BODY></HTML>  
补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,