MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 19th, 2000, 12:06 PM
Roman Kostinski Roman Kostinski is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 12 Roman Kostinski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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;

?>

Reply With Quote
  #2  
Old May 19th, 2000, 12:55 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,306 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 6 h 42 m 51 sec
Reputation Power: 60
look at the "addslashes()" and "stripslashes()" functions at www.php.net

While you're at it, you should also look at the "mysql_pconnect" function. (Opens a persistant connection--no need to open and close the connection for every INSERT)

Reply With Quote
  #3  
Old May 22nd, 2000, 10:04 AM
Roman Kostinski Roman Kostinski is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 12 Roman Kostinski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Dear Rycamor,

Thanks. It works.

Roman

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rycamor:
look at the "addslashes()" and "stripslashes()" functions at www.php.net

While you're at it, you should also look at the "mysql_pconnect" function. (Opens a persistant connection--no need to open and close the connection for every INSERT)
[/quote]


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > data transfer between 2 different MySQL servers

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap