morning all!

Does anyone know if its possible to connect to a remote host?

Basically we've got this site that requires you to be registered with a different site - so we need to check that before they can continue to the register page. So they'd type in there existing passwords for the remote host in the local hosts' site and then continue if its successful.
Also we'd like to populate some of the new register fields with info from the other host - mainly to save time and to make sure the info is all the same!

would this be possible? maybe with code like this at the bottom?
many thanks!

$host = "localhost";
$user = "xxx";
$pass = "xxxx";
$db = "xxx_database";

$host_b = "http://otherhosts-url-here.com";
$user_b = "yyyy";
$pass_b = "zzzz";
$db_b = "emailusers";

D.

    Yes, I'm quite sure you can, but the remote server have to be configured to allow the "local" IP to access the db.

    stiduck

      You could do it that way but it's probably easier to have the remote host have a PHP script that display's some XML. This way, you could use CURL, Pear, fopen, file, or file_get_contents. You pass in the u/p and the remote site returns a page of XML.

      There's nothing wrong with conninction MySQL to MySQL except that it's harder and that you're providing another attack vector to hackers.

        mmm - i thought it would be straightfwd but ran into a few problems;

        http://jynk.net/test/rs_test1.1.php

        <?php
        
        $host = "localhost";
        $user = "jynk";
        $pass = "???";
        $db = "jynk_net_-_main";
        
        $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
        mysql_select_db($db) or die ("Unable to select database!");
        
        $query = "INSERT INTO jynk_visits 
        (ss,clr, app, oss, lang, gotflash, ip) 
        VALUES 
        ('$ss','$clr', '$app', '$oss', '$lang', '$gotflash', '$ip')";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        
        $queryb = "SELECT * FROM jynk_visits LIMIT 10";
        $resultb = mysql_query($queryb) or die ("Error in query: $query. " . mysql_error());
        while ($row = mysql_fetch_array($resultb)) {
        	$ip = $row['ip'];
        	$ss = $row['ss'];
        	$oss = $row['oss'];
        	$lang = $row['lang'];
        	$app = $row['app'];
        	$gotflash = $row['gotflash'];
        	$clr = $row['clr'];
        
        	$users .= "$ip, $ss, $oss, $lang, $app, $gotflash, $clr.<BR>";
        }
        
        //$hostb = "ss88.shared.server-system.net";
        $hostb = "216.70.112.173";
        ///$hostb = "manandeve.co.uk";
        $userb = "manandeveco";
        $passb = "???";
        $dbb = "manandeve_co_uk_-_content";
        
        $connectionb = mysql_connect($hostb, $userb, $passb) or die ("Unable to connect!");
        mysql_select_db($dbb) or die ("Unable to select database!");
        
        $query = "SELECT * FROM exhibitions";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        
        while ($row = mysql_fetch_array($result)) {
        	$idb = $row['id'];
        	$title = $row['title'];
        	$artistname = $row['artistname'];
        	$covertitle = $row['covertitle'];
        	$covertext= $row['covertext'];
        	$coverstrap = $row['coverstrap'];
        	$s_date = $row['s_day'].".".$row['s_month'].".".$row['s_year'];
        	$e_date = $row['e_day'].".".$row['e_month'].".".$row['e_year'];
        
        $usersb .= "$title.<BR>";
        }
        
        print"$users<br />
        <br />
        $usersb";
        
        ?>

        is there another path to the host i'm not thinking of? can this help at all?http://jynk.net/phpinfo.php

        d.

          Looks like a hosting restriction - they need to allow remote connections to the mysql server which at the moment they are not. This blocking of remote connections is a widely used security measure so I doubt if they will change the server configuration for you - unless you are an important customer and paying a lot.

          2 options:

          Change hosting to someone who will allow remote connections - specifically pay enough to cover the extra administartion involved in allowing remote connections from specific domains and IPs.

          You can also send the login information to the remote website's login page as a normal http request from your server and see what you get back. That will bypass the need for a remote connection to the db. Trouble with this approach is that any changes to their site can break your script inadvertantly.

            thanks for the reply - i rekon they wont grant me access so will look into the http option. Maybe it could just syncronise the info from the remote table to the new one once a week? how would start the http option? D.

              Write a Reply...