RE: [PHP] Communicating with remote server

From: Warren Vail (Warren.Vail_at_schwab.com)
Date: 11/18/03

  • Next message: Jason Wong: "Re: [PHP] PHP process .html extension file"
    To: "'Webmaster'" <webmaster@sweetphp.com>, "'Jeff McKeon'" <jmckeon@telaurus.com>
    Date: Mon, 17 Nov 2003 18:12:49 -0800
    
    

    If you don't care who sees your data, or you are operating behind a
    firewall, then the simplest solution has already been mentioned (described
    as http).

    You basically code a script on your GTK app to perform an open (see fopen
    function) to a url on the server machine like
    "http://remotedbserver.com/phpfetchscript.php?var=foo&var2=bar" where foo
    and bar specify the data selection criterion for your database script.

    On the database server, under the control of it's web server, the script
    phpfetchscript.php executes, referencing the parameters passed in the url

    $var1 = $_GET["var"];
    $var2 = $_GET["var2];

    the phpfetchscript.php on the server then runs the query and begins echoing
    the comma separated columns from the database, perhaps ending with a new
    line "\n";

    Your GTK app now begins performing fgets reads against the data until fgets
    returns a false and does what it needs to do with the data, perhaps loading
    it into a grid control, or some such.

    The caviate is that anyone who can come up with the correct url (and can
    access your database machine), will be able to trigger the extract of data.
    If this is not acceptable, then you need to consider other options.

    good luck,

    Warren Vail

    -----Original Message-----
    From: Webmaster [mailto:webmaster@sweetphp.com]
    Sent: Monday, November 17, 2003 5:31 PM
    To: Vail, Warren; 'Jeff McKeon'
    Cc: php-general@lists.php.net
    Subject: RE: [PHP] Communicating with remote server

    Yes, both my server and the remote server have webservers with PHP
    installed. I have access to both servers to edit/modify/create files
    etc. I don't have SSH on the server's though. I have FTP access, so I
    can work with anything that way. I basically just need a relatively
    easy way to communicate back and forth between the servers. I just have
    no prior experience doing it so I need a little guidance.

    Thanks,

    Matt

    -----Original Message-----
    From: Vail, Warren [mailto:Warren.Vail@schwab.com]
    Sent: Monday, November 17, 2003 7:09 PM
    To: 'Webmaster'; 'Jeff McKeon'
    Cc: php-general@lists.php.net
    Subject: RE: [PHP] Communicating with remote server

    Lot's of options.

    Will this access be across the internet, or behind a firewall?

    Are you concerned about securing your information from prying eyes?

    You seem to be focusing on a script that runs on the remote machine,
    does
    this machine have a web server as well, or will you be executing PHP as
    a
    standalone process?

    I am taking it for granted that you have PHP installed on the remote
    machine?

    Do you have access to commands like REXEC, RCP, RSH, SSH on your local
    machine, and are the required daemons running on the remote machine?

    What platforms are involved at each end?

    Just a few questions that may have an impact on your solution...

    Warren Vail

    -----Original Message-----
    From: Webmaster [mailto:webmaster@sweetphp.com]
    Sent: Monday, November 17, 2003 2:19 PM
    To: 'Jeff McKeon'
    Cc: php-general@lists.php.net
    Subject: RE: [PHP] Communicating with remote server

    Well, I know how to run MySQL queries and connect to the db and things
    like that. But I would like to be able to connect to a remote site (ex:
    http://my-site.com/functions.php). Here I would like to run functions
    from the remote functions.php file and have it connect to it's own
    server's db. Then I want to be able to have certain information sent
    back to me. Maybe sockets is the best way to do this, but I don't know
    much about them. Any advice anyone?

    Matt

    -----Original Message-----
    From: Jeff McKeon [mailto:jmckeon@telaurus.com]
    Sent: Monday, November 17, 2003 5:14 PM
    To: Matt Palermo
    Cc: php-general@lists.php.net
    Subject: RE: [PHP] Communicating with remote server

    Matt Palermo wrote:
    > I am writing a desktop application using PHP-GTK. I would
    > like this program to be able to connect to a remote server,
    > call some functions that I specify, and return the right
    > information (most likely from a MySQL db). I have access to
    > the server, so I can create any and all functions that I
    > want, but I don't know how to connect to the remote server
    > page and get all the results. I am new to cross-server
    > comunication programming, so if anyone knows of a very
    > detailed and easy to learn tutorial please send me the link.
    > I would appreciate any help you are willing to offer.
    >
    > Thanks,
    >
    > Matt

    For mysql queries I use this...

    function db_connect($dbhost,$dbname,$dbuser,$dbpass) {

            global $MYSQL_ERRNO, $MYSQL_ERROR;
            
            $link = mysql_connect($dbhost,$dbname,$dbuser,$dbpass);
            if (!$link_id) {
                    $MYSQL_ERRNO = 0;
                    $MYSQL_ERROR = "Connection failed to the host $dbhost";
                    return 0;
            }
            else if(empty($dbname) && !mysql_select_db($dbname)) {
                    $MYSQL_ERRNO = mysql_errno();
                    $MYSQL_ERROR = mysql_error();
                    return 0;
            }
            else return $link;
    }

    $link_id=db_connect(dbname,db_user_name,db_user_pass);
    Mysql_select_db(dbname, $link_id);

    $query="select * from tablename";

    $result=mysql_query($query);

    While ($query_data=mysql_fetch_row($result))
    {
            echo $query_data[0],$query_data[1],$query_data[2],etc
    }

    Jeff

    -- 
    PHP General Mailing List (http://www.php.net/)
    To unsubscribe, visit: http://www.php.net/unsub.php
    

  • Next message: Jason Wong: "Re: [PHP] PHP process .html extension file"

    Relevant Pages

    • Re: copy folder to remote server
      ... copy folder to remote server ... copy folder to remote server ... Your search - madunix - did not match any documents. ...
      (RedHat)
    • Re: where did all the files go
      ... the local web site folder to a remote test server and delete the local ... the pages to a remote server, are the files that are copied to the remote ... You can then back up the entire folder ... VS2005 has a Publish Web Site option that enables you to publish to ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: Configuring GNOME to automatically start screensaver after user logged in - Fedora Core 6
      ... I can now remotely connect to the native X display of the ... remote server without having to log into the remote server first ... it presents me with a login and I am able to log in. ...
      (linux.redhat)
    • Trying to understand DCOMs network traffic
      ... I have a server object which runs as an out process exe on my remote ... has been created on the remote server and then goes happily on its way. ... Dim oRemoteServerObj as object ... Dim vResults as variant ...
      (microsoft.public.win32.programmer.ole)
    • Trying to understand DCOMs network traffic
      ... I have a server object which runs as an out process exe on my remote ... has been created on the remote server and then goes happily on its way. ... Dim oRemoteServerObj as object ... Dim vResults as variant ...
      (microsoft.public.vb.com)