一個連接兩個不同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>  

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。