·您的位置: 首页 » 资源教程 » 编程开发 » PHP » 一个连接两个不同MYSQL数据库的PHP程序

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

类别: PHP教程  评论数:0 总得分:0
<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>  
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1