RE: Update remote mysql database from localhost by PHP- Is it posibble? is it safe?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I want to update my database on remote server in the way
> i can read data from database on localhost and transfare it to
> remote database.I have done that in this way but i didnt get any
> result.could any one tell me haw i can do it?
> 
> //-------local connection
> $link = mysql_connect ("localhost", "localuser", "local password")
> or die ("I can't connect with DataBase :(");
> mysql_select_db ("my local database") or die ("I'm connecting with
> Database Server On localhost but I can't select your DB.");
> 
> //-------remote connection
> $link_server = mysql_connect
> ("www.nyserver.com", "myuser", "mypass") or die ("I can't connect
> with DataBase :(");
> mysql_select_db ("my database") or die ("I'm connecting with
> Database Server On shiasearch.com but I can't select your DB.");
> 
> 
> $query="select id, text FROM test_update limit $min,1000";
> $max = $min + 1000;
> $result = mysql_query($query, $link);
> $i = 0;
> while ($row = mysql_fetch_array ($result)){
> 	   $i++;
> 	   $result2 = mysql_query($row[2], $link_server);
> 
> }//while
> 	   echo "<a href=\"update.php?min=$max\">[$i records
> Updated] ---- NEXT</a>";

It's difficult to tell what you want to do, but first thing I notices is
this line: $result2 = mysql_query($row[2], $link_server);

1. You are getting 2 fields and fetching as an array, so $row[2] will be
empty.
2. it looks like you are trying to execute some field (from you local
server) as a query on a remote server.  Is that right?


-D. Israel
dan@xxxxxxxx
http://www.customcodebydan.com 
AIM: JudoDanIzz

A BANDAID!? Damn it Jim,I'm a doctor,not a-oh, never mind

> -----Original Message-----
> From: alireza_353 [mailto:alireza_353@xxxxxxxxx]
> Sent: Wednesday, March 05, 2008 12:55 AM
> To: php-objects@xxxxxxxxxxxxxxx
> Subject:  Update remote mysql database from localhost by
> PHP- Is it posibble? is it safe?
> 
> I want to update my database on remote server in the way
> i can read data from database on localhost and transfare it to
> remote database.I have done that in this way but i didnt get any
> result.could any one tell me haw i can do it?
> 
> //-------local connection
> $link = mysql_connect ("localhost", "localuser", "local password")
> or die ("I can't connect with DataBase :(");
> mysql_select_db ("my local database") or die ("I'm connecting with
> Database Server On localhost but I can't select your DB.");
> 
> //-------remote connection
> $link_server = mysql_connect
> ("www.nyserver.com", "myuser", "mypass") or die ("I can't connect
> with DataBase :(");
> mysql_select_db ("my database") or die ("I'm connecting with
> Database Server On shiasearch.com but I can't select your DB.");
> 
> 
> $query="select id, text FROM test_update limit $min,1000";
> $max = $min + 1000;
> $result = mysql_query($query, $link);
> $i = 0;
> while ($row = mysql_fetch_array ($result)){
> 	   $i++;
> 	   $result2 = mysql_query($row[2], $link_server);
> 
> }//while
> 	   echo "<a href=\"update.php?min=$max\">[$i records
> Updated] ---- NEXT</a>";
> 
> 
> 
> 
> Are you looking for a PHP job? Join the PHP Professionals directory
> Now!
> http://www.phpclasses.org/professionals/
> Yahoo! Groups Links
> 
> 
> 


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux