
May 19th, 2000, 12:06 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hi,
I need to transfer data from one MySQL server to another one by php script. I have a simple script that takes all data from table "contact" of MySQL database "test" on remote server and transfer them to table "contact" of another MySQL database "all" on local server.
Everything works fine even if table "contact" contains a lot of records.
But if a field contains ' (for example O'Brian in the name field ) this record does not transfer at all.
Could somebody help?
Thanks in advance.
Roman
e-mail: roman@astelit.ru
Here is above mentioned script named transfer.php3 :
<?php
Function Transfer () { global $id, $name, $email, $extension, $nick
mysql_connect("remote host name","username","password");
$database="test";
@mysql_select_db($database) or die( "Unable to select database");
$query="insert into contact values('$id','$name','$email','$extension','$nick')";
$result=mysql_query($query);
}
mysql_connect(localhost,username,password);
$database="all";
@mysql_select_db("$database") or die( "Unable to select database");
$table="contact";
$query="select * from $table";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num):
$name=mysql_result($result,$i,"name");
$email=mysql_result($result,$i,"email");
$extension=mysql_result($result,$i,"extension");
$nick=mysql_result($result,$i,"nick");
$id=mysql_result($result,$i,"id");
Transfer ();
$i++;
endwhile;
?>
|