网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2024/11/16 浏览:3 次 )
<HTML><BODY BGCOLOR=FFFFFF>  
<?php  
    echo "Connecting as mysql<BR>\n";  
    $connection1 = mysql_connect('localhost', 'mysql', '') or die($php_errormsg);  
    echo "connection1 is $connection1<BR>\n";  
    echo "Selecting test for mysql user<BR>\n";  
    mysql_select_db('test', $connection1) or @die("Error " . $php_errormsg . mysql_error());  
    echo "Connection as joyce<BR>\n";  
    $connection2 = mysql_connect('localhost', 'joyce', '') or die($php_errormsg);  
    echo "connection2 is $connection2<BR>\n";  
    echo "Selecting books for joyce user<BR>\n";  
    $db2 = mysql_select_db('techbizbookguide', $connection2) or die(mysql_error());  
    $query1 = "select foo from test";  
    $query2 = "select title, authorFirst, authorLast from bookinfo";  
    echo "Querying test<BR>\n";  
    $users = mysql_query($query1, $connection1) or die(mysql_error());  
    echo "Querying books<BR>\n";  
    $books = mysql_query($query2, $connection2) or die(mysql_error());  
    echo "Foos from test<BR>\n";  
    while (list($foo) = mysql_fetch_row($users)){  
        echo $foo, "<BR>\n";  
    }  
    echo "Books in techbizbookguide<BR>\n";  
    while (list($title, $authorFirst, $authorLast) = mysql_fetch_row($books)){  
        //Use trim in case we have a book by "Madonna" or "Prince" or...  
        echo $title, ' by ', trim($authorFirst . ' ' . $authorLast), "<BR>\n";  
    }  
?>  
</BODY></HTML>  
上一篇:杏林同学录(七)
下一篇:我的论坛源代码(一)
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。