|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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; ?> |
|
#2
|
|||
|
|||
|
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) |
|
#3
|
|||
|
|||
|
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] |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > data transfer between 2 different MySQL servers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|