-
您的位置:首页 → 网页设计 → PHP技巧 → 一个连接两个不同MYSQL数据库的PHP程序
一个连接两个不同MYSQL数据库的PHP程序
时间:2004/11/7 3:16:00来源:本站整理作者:蓝点我要评论(0)
-
echo "Connecting as mysql
\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";
}
?>
相关阅读
Mac和Windows哪个好 windows和mac os对比介绍Win10预览版怎么升级 Win10预览版升级方法厂商不再预装Win7或8.1系统,驱动人生帮您快速升级Mac移动硬盘安装win8 Mac将win装在移动硬盘使用教程windows10xboxone串流简单教程Windows Hello怎么用 Windows Hello使用设置教程win10怎么关闭自动更新 win10如何关闭自动更新Mac系统如何远程桌面到Windows系统
-
热门文章
没有查询到任何记录。
最新文章
如何恢复Discuz!7.0被
CSS实现Tab技巧Linux配置DHCP服务器实例:linux配置教程如何在IIS7下设置支持PHP程序PHP技巧--通过COM使用ADODB
人气排行
dedecms数据库表和字段说明最小化数据传输——在客户端存储数据php如何自动跳转中英文页面如何在IIS7下设置支持PHP程序php批量获取首字母(汉字、数字、英文)经典php实现大文件上传源代码Windows环境PHP的session不能正常使用解决办PHP聊天室技术
查看所有0条评论>>