sql+php help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dejan

    #1

    sql+php help

    hy

    I have two mysql servers. One is on my local comp (localhost) and the other
    is something.com
    Creating simple php script to do this...

    ----------------------------------------------------------------------
    $db1 = mysql_connect(" something.com", "username", "pass") or die("Could not
    connect.");
    if(!$db1)
    die("no db");
    if(!mysql_selec t_db("smjestaj" ,$db1)) die("No database selected.");


    $db2 = mysql_connect(" localhost", "username", "pass") or die("Could not
    connect.");
    if(!$db2)
    die("no db");
    if(!mysql_selec t_db("smjestaj" ,$db2)) die("No database selected.");

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

    i nead to execute this query on my local comp's web server.

    update table2
    set zauzetost = t1.zauzetost
    from table2 t2, table1 t1
    where t2.id = t1.id


    table2 is on remote server, table1 is on local comp.
    How to do this? I'm poor coder, so...

    tnx in advance on your brain cells.
    Dejan



  • J.O. Aho

    #2
    Re: sql+php help

    Dejan wrote:
    hy
    >
    I have two mysql servers. One is on my local comp (localhost) and the other
    is something.com
    Creating simple php script to do this...
    >
    ----------------------------------------------------------------------
    $db1 = mysql_connect(" something.com", "username", "pass") or die("Could not
    connect.");
    if(!$db1)
    die("no db");
    if(!mysql_selec t_db("smjestaj" ,$db1)) die("No database selected.");
    >
    >
    $db2 = mysql_connect(" localhost", "username", "pass") or die("Could not
    connect.");
    if(!$db2)
    die("no db");
    if(!mysql_selec t_db("smjestaj" ,$db2)) die("No database selected.");
    >
    ----------------------------------------------------------------------
    >
    i nead to execute this query on my local comp's web server.
    >
    update table2
    set zauzetost = t1.zauzetost
    from table2 t2, table1 t1
    where t2.id = t1.id
    >
    >
    table2 is on remote server, table1 is on local comp.
    How to do this? I'm poor coder, so...
    You query table1 and table2 and store those in two multi dimensional arrays,
    then you create your third multi dimensional array into where you store the
    joint rows of table1 and table2.


    //Aho

    Comment

    • Dejan

      #3
      Re: sql+php help

      Yeah right. I have tried playing with multidimensiona l arrays, buth with my
      knowlege :))

      Why cann't i use this with what sql query?

      You query table1 and table2 and store those in two multi dimensional
      arrays,
      then you create your third multi dimensional array into where you store
      the
      joint rows of table1 and table2.
      >
      >
      //Aho

      Comment

      • Jerry Stuckle

        #4
        Re: sql+php help

        Dejan wrote:
        Yeah right. I have tried playing with multidimensiona l arrays, buth with my
        knowlege :))
        >
        Why cann't i use this with what sql query?
        >
        >
        >
        >>You query table1 and table2 and store those in two multi dimensional
        >
        arrays,
        >
        >>then you create your third multi dimensional array into where you store
        >
        the
        >
        >>joint rows of table1 and table2.
        >>
        >>
        > //Aho
        >
        >
        >
        Unless something has changed, you can't query across databases on
        different servers.

        Also, if you ask a question in a PHP group expect to get a PHP response.
        If you want a MySQL response, try a MySQL group such as
        comp.databases. mysql.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Mel

          #5
          Re: sql+php help

          On 2006-07-11 21:58:26 +1000, Jerry Stuckle <jstucklex@attg lobal.netsaid:
          Dejan wrote:
          >Yeah right. I have tried playing with multidimensiona l arrays, buth with my
          >knowlege :))
          >>
          >Why cann't i use this with what sql query?
          >>
          >>
          >>
          >>You query table1 and table2 and store those in two multi dimensional
          >>
          >arrays,
          >>
          >>then you create your third multi dimensional array into where you store
          >>
          >the
          >>
          >>joint rows of table1 and table2.
          >>>
          >>>
          >> //Aho
          >>
          >>
          >>
          >
          Unless something has changed, you can't query across databases on
          different servers.
          >
          Also, if you ask a question in a PHP group expect to get a PHP
          response. If you want a MySQL response, try a MySQL group such as
          comp.databases. mysql.
          I don't know if it's valid SQL (or just T-SQL), but:
          MSSQL supports connecting to multiple servers in a single statement. Ex:
          select tbl1.*, tbl2.*
          from localhost.myloc aldatabase.dbo. table_one as tbl1
          join otherhost.myrem otedatabase.dbo wner.table_two as tbl2 on tbl1.id = tbl2.fk

          Comment

          Working...