Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Interbase and PHP rearing its ugly head again!!

Options
  • 25-03-2002 3:37pm
    #1
    Registered Users Posts: 14,148 ✭✭✭✭


    I'm attempting to get a php script to connect to an interbase database on another machine (just connection for now to establish communications, more stuff can come later).

    the php script is running off of apache on an rh 7.2 machine, whilst the machine with the relevant interbase dbase on it is a windows 2000 machine.

    The code is as follows:

    <?php
    function dbaseCall()
    {
    if($dbObj = iConnect())
    {
    echo "Connection Successful!\n<br>\n" ;
    iClose($dbObj) ;
    }
    }

    function iConnect()
    {
    $hostname = "interbase:r:\\trans\\db\\transhost.gdb" ;
    $username = "xxxxxxxxx" ;
    $pwd = "xxxxxxxx" ;
    $charset = "ISO8859_1" ;

    $dbObj = ibase_connect ('$hostname', '$username', '$pwd', '$charset', 0, 1)
    or die ("Could not connect<br>\n") ;

    return $dbObj ;
    }

    function iClose($dbObj)
    {
    if(!ibase_close($dbObj))
    echo "Connection still open!<br>\n" ;
    }
    ?>

    <html>
    <head>
    <title>InterBase Connection Test</title>
    </head>

    <body>
    <? dbaseCall() ; ?>
    </body>
    </html>


    Now, the host "interbase" is a named machine in the rh 7.2 machine's host file and maps to a specific ip# -> x.x.x.26

    The error message I get upon attempting to run the script is the following:

    Warning: InterBase: Unable to complete network request to host "localhost". Failed to establish a connection. Connection refused in /var/www/html/xxxxxx/itest/test.php on line 18
    Could not connect

    Anyone got any ideas??


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Hey Lemming,

    "localhost" is the local machine, i.e. your script is trying to connect to an Interbase server on the server the script is sitting on. You need to change this to the IP or hostname of the machine you want to connect to. In other words, your DSN (interbase:r:\\trans\\db\\transhost.gdb) is wrong...

    adam


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by dahamsta
    Hey Lemming,

    "localhost" is the local machine, i.e. your script is trying to connect to an Interbase server on the server the script is sitting on. You need to change this to the IP or hostname of the machine you want to connect to. In other words, your DSN (interbase:r:\\trans\\db\\transhost.gdb) is wrong...

    adam

    Well, the way I had "interbase" set up was that its listed in the rh machine's hosts file along with the relevant IP as I already mentioned.

    But anyway, substituting the ip address x.x.x.26 in place of "interbase" to read "x.x.x.26:r:\\trans\\db\\transhost.gdb" still gets the same error message.

    That's what I can't understand. When I'm specifying another machine, the script keeps ranting on about the local machine :confused:


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Well, the way I had "interbase" set up was that its listed in the rh machine's hosts file along with the relevant IP as I already mentioned.

    But anyway, substituting the ip address x.x.x.26 in place of "interbase" to read "x.x.x.26:r:\\trans\\db\\transhost.gdb" still gets the same error message.


    Well, your DSN looks odd to me, but I'm not used to Interbase. That said, if you're still getting the error with "localhost", it implies that PHP is trying to connect to the local machine.

    How about permissions on the Interbase server? Is it configured to allow you to connect from the machine the PHP script is on?

    adam


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    This is fluppin' bizarre

    It's working. And do you want to hear how???

    instead of feeding variables into the connection statement, you place the variable info. instead

    so its reading something like

    ibase_connect("host:blah\\blah\\dbase.gdb", "usrname", "pwd") ;

    wtf??? :confused:

    Why didn't the variables work??!!


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    I'm ashamed of myself for not spotting it:
    $dbObj = ibase_connect ('$hostname', '$username', '$pwd', '$charset', 0, 1);
    
    You have the vars in single quotes. Vars aren't expanded in single quotes, so PHP was literally trying to connect to '$hostname'. The ibase_connect() line should read:
    $dbObj = ibase_connect ($hostname, $username, $pwd, $charset, 0, 1);
    
    See here, in particular the second note. And apologies for not spotting it sooner.

    adam


  • Advertisement
  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by dahamsta
    I'm ashamed of myself for not spotting it:

    hang your head in shame!!! :p You're not 'lite enough to be a "HaXor".

    But seriously dahamsta, I always knew it was something stupid staring me in the face and laughing at me. Cheers for trying. Muchos appreciated :)


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Well, next time I promise to stare you in the face and laugh at you. Because I am STUPID! :)

    adam


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by dahamsta
    Well, next time I promise to stare you in the face and laugh at you. Because I am STUPID! :)

    adam

    I shall be sure to eat a clove of garlic or some suitably smelly foodstuff before you stare me in the face.

    I'll just wait until you're in the throes of laughter first and gagging for air! Why bruise them when you can lop the proverbial limb off ;)

    MWWUAAHAAHAAHAAA

    What are we going to do tonight Brain?? Same thing we do every night Pinky ..... try to take over the worrrrrrrlllldddddd!!

    Pinky and the brain, brain, brain, brain, brain, brain brain brain brainnnn......

    Oh dear god .. I need to stop drinking so much coffeeeeeeemkasl' nglasdmngsbjkavgfdslj,bv WEEEEHOOOOO BIG DOG!! BIG dogs LICKING AT MY FACEE!!!!

    [edit]Excuse me, I don't quite know what just happened there.

    /me runs quickly away
    [/edit]


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Freak.


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by dahamsta
    Freak.

    /me takes a bow

    Thank you, thank you my legions of adoring fans!! :D


  • Advertisement
  • Registered Users Posts: 7,410 ✭✭✭jmcc


    That literal problem can be tricky. :) If you think that is bad, you should see the problems that llength can cause in tcl. Almost made me consider using Visual Basic. :)

    Seriously though, if you are going to deploy this in a live (internet connected) environment, block access to the Interbase port at the firewall if you can and go private IP on the database server. Some of the older versions of Interbase had a backdoor username/password.

    Regards...jmcc


Advertisement