473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to update remote databse from local databse using PHP ?

Hi all

I need help to update a remote mysql database from a local mysql database using php run in remote site.

Use of application
1. The local database and the reomote database are same structure
2. Some part of updation are done localy and then manully export the the local file and import in remote site . I need help to change this operation by running a scipt in remote server and auomatically update the remote databse from the local databse

If any one know the idea how to do it . please help me ..

Thank you all
Jul 16 '10 #1
8 3223
code green
1,726 Expert 1GB
I suggest first writing a test script that connects to both databases and reads from both databases.
That way any permissions problems can be ironed out.

Once there is an open connection between both databases in the same script, data can be processed and transferred via arrays.

Another way around is ftp and mysqldump.
Update the db locally and run mysqldump.
FTP the dump file to the remote site.
Run mysqldump on remote.
You would need DROP TABLE IF EXISTS in the dump queries so in effect the remote db gets trashed and rebuilt.

Just a footnote, PHP FTP functions are easy to use but mysqldump is difficult.
Jul 16 '10 #2
@code green
Hi first I could thank for your comments .

I used the mysql dump . Exactly what I need is a way to acces local database file to the reomote page.

I have an ftp acces and database access in remote machine . I need to update some of the tables auomaticaly (Daily by setting a clock or by clicking a button).

Can you show some code snippet for doing that ?

I dont know how to access the local database in my client machine to the remote site

Lot of Thanks
Jul 16 '10 #3
code green
1,726 Expert 1GB
dont know how to access the local database in my client machine to the remote site
It is not HOW but CAN that is tricky with a remote site.
Connecting to a remote database is similar to connecting to a local database
Expand|Select|Wrap|Line Numbers
  1. mysql_connect('url','username', 'password');
URL - This is the address to the database server such as
'mysite.com/phpMyAdmin/'
But the ip address is more reliable than the domain name
Then
Expand|Select|Wrap|Line Numbers
  1. mysql_select_db('database_name')
Can you show some code snippet for doing that ?
Use mysql_query() to run a query. It is the query itself which is the more difficult/important
Jul 16 '10 #4
Hi
I used the following function in my local system


Expand|Select|Wrap|Line Numbers
  1. function connectdb()
  2. {
  3. $con = mysql_connect('http://<MY IP ADDRESS>/phpmyadmin/', 'dbuser', 'dbpass');
  4. if (!$con)
  5.   {
  6.   die('Could not connect: ' . mysql_error());
  7.   }
  8.  
  9. mysql_select_db("mydbname", $con);
  10. }
  11. connectdb();
  12.  

but i get the following error

Expand|Select|Wrap|Line Numbers
  1. Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'IPADDRESS' (4) in '<PATH>' on line 2
  2. I cannot connect to the database because: Can't connect to MySQL server on 'IPADDRESS' (4)
  3.  
  4.  
what can I do ? please help me.


Thank you
Jul 17 '10 #5
code green
1,726 Expert 1GB
Remove the 'http://' bit.
Have you got the address correct?
Is the database in phpmyadmin?
Try with the IP addres and not the domain name
Jul 19 '10 #6
also, the port!
Jul 19 '10 #7
Hi
Thanks a lot to touch with me.

I did not get the connection from local machine with the specified IP address. It had done with as usual procedure. Dump my local database and the import in the Remote server . I m trying to find some way to do this.

Thanks . thanks a lot
Jul 19 '10 #8
code green
1,726 Expert 1GB
Dump my local database and the import in the Remote server
FTP. PHP FTP functions work fine
Jul 19 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: RadhakrishnanR | last post by:
Hi, How to copy a file from SFTP server to local PC using Batch file. Please consider that SFTP server is installed in Linux OS NOT in Windows OS. i.e. I need Batch file script to do the above...
0
by: subiparihar | last post by:
Hi guys, I m currently facing a problem , in copying a doc file to the web server from the local machine using c#. Pls suggest some Support. Thank You Subi
1
by: yellowblueyellow | last post by:
Hi, I want to list all groups on a local machine using C#. How do I go about this? Thanks
2
by: yellowblueyellow | last post by:
Hi, I need a function to List all users in a group on a local computer using C#. any assistance would be much appreciated
1
by: shaji66 | last post by:
how to update values in HTML page using java script: hi all , I want to update some text fields in html , and display these values in another page .... can you please help me in writing...
0
by: CaptainPicard | last post by:
Hi, I was wondering what the code is to search a local DB using VB. I currently have my app attached to the DB, but I dont know what the commands are to search. The database is the names of...
5
by: naamala | last post by:
Hi, How can i get unused/available port in the local system using C# ? Or Is there any way to find out whether the particular port number is being used by any other application using C#? ...
1
by: krishemanth | last post by:
sir, I want to update a value in dropdown using ajax i had a listing of some categories in dropdown along with that i had an add category in that dropdown box when select that addcategory option...
3
by: subhashinivasan | last post by:
How to get version of the oracle installed in Local Machine using VB.NET. Please do reply at the earliest Thanks, Subha
5
by: JohnLorac | last post by:
Hello, can somebody help me with saving file into local disk using javascript? I made some sample code which unfortunately won't work :(. Applet sample file: public class IO extends...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.