SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    require() script on other domain

    Hi, I have a few sites on different domains and a class library on another domain which I'd like to require() into all scripts on the different domains. Would require("domain.com/script.php") work ? If yes under which circumstances ?

    2nd question:
    3 forums: same database, shared members table, same domain

    one site: another domain

    I want to access that members table from the site

    how ?

    TIA.

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Hi, I have a few sites on different domains and a class library on another domain which I'd like to require() into all scripts on the different domains. Would require("domain.com/script.php") work ? If yes under which circumstances ?
    Provided your server isn't running Windows (or is > 4.3.0), and your administrator has enabled allow_url_fopen in the php.ini, require *would* work, and usually work well:

    Quote Originally Posted by php.net manual
    Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.
    Quote Originally Posted by DarkAngelBGE
    3 forums: same database, shared members table, same domain
    one site: another domain
    I want to access that members table from the site
    That might prove a bit more difficult -- as your server would have to allow remote database connections. *Possible* but usually disabled for security reasons. Check with your hosting company to determine if they allow this.

    Note, if you are on the *same* server, you can just access that table like any other (provided you have the username / password)
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would this also work when the forums are on a subdomain of the domain where the site is ? I mean work in the normal way.

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Would this also work when the forums are on a subdomain of the domain where the site is ? I mean work in the normal way.
    As long as your subdomains have read / write access to your source directory, yes
    My name is Steve, and I'm a super-villian.

  5. #5
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would a sql query look if I want to join 2 tables that are both on another database ?

    Would I have to make 2 db connections and then

    "...FROM dbname1.tblname1 AS b, dbname1.tblname1 AS c..."

    ?

  6. #6
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it should
    My name is Steve, and I'm a super-villian.

  7. #7
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Note however that requiring a remote PHP file will not cause the execution to happen within your script, all that will happen is you'll get the content output of said script.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  8. #8
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jeff Lange
    Note however that requiring a remote PHP file will not cause the execution to happen within your script, all that will happen is you'll get the content output of said script.
    Duh, that's bad. :S

  9. #9
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Duh, that's bad. :S
    Of course, that's if you require across domains -- if you just require, on the same server, the appropriate path, this isn't an issue
    My name is Steve, and I'm a super-villian.

  10. #10
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok ay next question.

    How would a sql query look if I want to join 2 tables that are both on another database ? One database is on a domain and the other one is on a subdomain of that domain (that's the difference to the last question regarding databases) ?

  11. #11
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Ok ay next question.

    How would a sql query look if I want to join 2 tables that are both on another database ? One database is on a domain and the other one is on a subdomain of that domain (that's the difference to the last question regarding databases) ?
    Both tables are on the same database?

    PHP Code:
    mysql_select_db('...');
    mysql_query('...'); 
    Or one table is on the subdomain database, and one on the regular domain database?

    PHP Code:
    mysql_select_db('...');
    mysql_query('SELECT db1.tb1.c1, db2.tb1.c1 FROM db1.tb1, db2.tb2...'); 
    This will only work if the user passed to mysql_connect has read access to both databases.
    My name is Steve, and I'm a super-villian.

  12. #12
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, well two different databases is what I meant. Would I have to use mysql_select_db() twice in a row ? I doubt that as only one db can be selected at the same time, no ?

  13. #13
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DarkAngelBGE
    Yeah, well two different databases is what I meant. Would I have to use mysql_select_db() twice in a row ? I doubt that as only one db can be selected at the same time, no ?
    If you select a different database, you 'lose' access to the old one, unless you refer to them in the database.table format as shown in the second example.

    But, if one database requires 'user1' / 'pass1', and the second requires 'user2' / 'pass2', I don't see anyway to merge the data. You'll have to perform separate connections, and parse the result in PHP.
    My name is Steve, and I'm a super-villian.

  14. #14
    SitePoint Wizard
    Join Date
    May 2003
    Location
    Berlin, Germany
    Posts
    1,829
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright thanks, I will see if this works out.


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
  •