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

5年以前  |  阅读数:657 次  |  编程语言:PHP 
\n"; $connection1 = mysql_connect('localhost', 'mysql', '') or die($php_errormsg); echo "connection1 is $connection1
\n"; echo "Selecting test for mysql user
\n"; mysql_select_db('test', $connection1) or @die("Error " . $php_errormsg . mysql_error()); echo "Connection as joyce
\n"; $connection2 = mysql_connect('localhost', 'joyce', '') or die($php_errormsg); echo "connection2 is $connection2
\n"; echo "Selecting books for joyce user
\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
\n"; $users = mysql_query($query1, $connection1) or die(mysql_error()); echo "Querying books
\n"; $books = mysql_query($query2, $connection2) or die(mysql_error()); echo "Foos from test
\n"; while (list($foo) = mysql_fetch_row($users)){ echo $foo, "
\n"; } echo "Books in techbizbookguide
\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), "
\n"; } ?>
 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例