SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Fatal Error

  1. #1
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fatal Error

    Hi all,

    I am using a file called "connect.php" as an include to connect to a mysql database. My method of including this files has been as follows:
    PHP Code:
    <?php // accesscontrol.php
    include 'connect.php';
    .
    .
    .
    However, this file will soon be on a different domain, so I will need to specify the url rather than just the filename.
    PHP Code:
    <?php // accesscontrol.php
    include 'http://localhost/admin/connect.php';
    .
    .
    .
    When I try this I get an error saying it cannot find the function within the include file...

    Fatal error: Call to undefined function: dbconnect() in E:\innovativedevelopers_net\admin\accesscontrol.php on line 10

    Now I know it is finding the file via the url, I already verified that...It's just not able to find the function in the file via the url.

    Any suggestions?

    Thanks,
    David

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    ini_set('include_path',ini_get('include_path').':'$_SERVER['DOCUMENT_ROOT'].'/admin');
    require_once 
    'connect.php'

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    So if the file connect.php is moved off my server to another server, what would I have to modify on your code?

  4. #4
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, i thought you meant the whole site would/might be moved not just content.php, sorry

    This is tricky, as if you include 'http://some.remote/file.php'; then you'll actually be including the parsed output of file.php, and not the 'raw' file.php itself. This is why you got the function undefined error previously.

    Perhaps others can correct me here, but the only way i can think of doing it is to do
    include 'http://wherever.com/connect.php';
    and put the dbconnect() call inside connect.php itself.

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll give it a try.......

  6. #6
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still having trouble, how bout I describe my original goal and see if you have any suggestions for a better approach.

    I need to connect to various client's mysql databases on various servers. The website that needs to connect to these databases is on my computer. It is my understanding that I cannot connect to them directly from my site because there servers will only accept a request to connect to mysql via localhost, not via the servers ip address.
    Therefore, I am attempting to place the connect code on my clients server so it can connect to localhost, and access the database via my site (because in theory it is already connected to their mysql)

    Anyway, I'm running down a dead end...any ideas?

    thanks,
    Dave

  7. #7
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the simplest solution is to ask them to allow access to mysql from your ip. They shouldn't have a problem with this if they are happy to put one of your scripts on their server

    My only other thinking takes my down the XML-RPC/SOAP route, which is overkill of course.

  8. #8
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They are hosted by other companies, I don't think they will have conrol of the mysql settings


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
  •