SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2002
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question I only have 1 MySQL Database and need it to run several scripts req seperate db??

    Hi,
    I am looking for advice on how to run several different scripts from just 1 MySQL db?

    I imagine I can simply define a table name value ie

    $table_name = "name";

    into the script connection string??

    If not can someone point me in the right direction?

    Thanks in advance

    Ed

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are correct. Create all the instances you need from the db you wish. Then be sure when you are querying the db you specify the var it is assigned to.

    In this way you can work with all db's and thereby all tables in the mysql server.



    $cnx=mysql_connect("","root","blah");
    $db1=mysql_select_db("bobDB",$cnx);
    $db2=mysql_select_db("bobDb2",$cnx);

    $query=mysql_query("select * from articls",$db1);
    $query2=mysql_query("select * from authors",$db2);

    I am sure you get the idea. You have two different databases being used at the same time with different instances of mysql.

    http://www.php.net/manual/en/function.mysql-query.php
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •