zoukankan      html  css  js  c++  java
  • PHP同时操作多个MySQL连接

    <?php
    $con_1 = mysql_connect('localhost','root','')or die("<font color=red>不能连接数据库!</font>");
    mysql_select_db('gameupload',$con_1);
    $con_2 = mysql_connect('localhost','root','')or die("<font color=red>不能连接数据库!</font>");
    mysql_select_db('blog4',$con_2);
    $sql = "select * from user limit 2";
    $res = mysql_query($sql,$con_1);
    echo mysql_error();
    while($row = mysql_fetch_assoc($res)){
    	print_r($row);
    }
    ?>


    运行结果:只显示gameupload里的user内容。

    -------------------------------

    <?php
    $con_1 = mysql_connect('localhost','root','')or die("<font color=red>不能连接数据库!</font>");
    mysql_select_db('gameupload',$con_1);
    $con_2 = mysql_connect('127.0.0.1','root','')or die("<font color=red>不能连接数据库!</font>");
    mysql_select_db('blog4',$con_2);
    $sql = "select * from user limit 2";
    $res = mysql_query($sql,$con_1);
    echo mysql_error();
    while($row = mysql_fetch_assoc($res)){
    	print_r($row);
    }
    ?>

    运行结果:显示blog4里的user内容。

    ------------------

    参考来源:http://blog.csdn.net/iamtrooper/article/details/4139209

  • 相关阅读:
    埋点功能测试
    jmeter提取A接口返回值传入B接口
    css(2)---倒角阴影 框模型
    css(1)
    node 练习
    学习过程中遇到的问题及解决方法
    node.js(5)——mysql、连接池
    node.js(4)——中间件
    node.js(3)——express
    node.js(2)
  • 原文地址:https://www.cnblogs.com/y0umer/p/3838796.html
Copyright © 2011-2022 走看看