RE: [PHP] Communicating with remote server

From: Jeff McKeon (jmckeon_at_telaurus.com)
Date: 11/17/03


Date: Mon, 17 Nov 2003 17:14:16 -0500
To: "Matt Palermo" <webmaster@sweetphp.com>

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



Relevant Pages

  • Re: [PHP] Communicating with remote server
    ... Matt Palermo wrote: ... > I am writing a desktop application using PHP-GTK. ... but I don't know how to connect to the remote server page and get all ...
    (php.general)
  • Re: [PHP] Communicating with remote server
    ... Matt Palermo wrote: ... but I don't know how to connect to the remote server page and get all ... If the remote server has webserver with php, you can use http protocol ... or even php code that you will eval ...
    (php.general)
  • RE: [PHP] Communicating with remote server
    ... I know how to run MySQL queries and connect to the db and things ... Communicating with remote server ... Matt Palermo wrote: ... > comunication programming, so if anyone knows of a very ...
    (php.general)
  • Communicating with remote server
    ... I am writing a desktop application using PHP-GTK. ... but I don't know how to connect to the remote server page and get all ...
    (php.general)