You may not need to use PHP at all for this. MySQL has replication capabilities built into it that can be turned on. See chapter 16 of the MySQL manual - http://dev.mysql.com/doc/refman/5.0/en/replication.html
MySQL database sync betwen two servers using PHP
题
I have the same website on two different servers.
Master Database - server1
Slave Database - Server2
I want to make PHP script which will check for changes in master database and if found any it will syncronize it with slave database. I will set chronjob for that script so it will run every few minutes.
I found some scripts on Google but it doesn't work at all. I tried using PMS but I'm receiving:
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant user - assumed 'user' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant pass - assumed 'pass' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant base - assumed 'base' in /var/www/demos/pms/pmslib.php on line 63
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 79
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant user - assumed 'user' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant pass - assumed 'pass' in /var/www/demos/pms/pmslib.php on line 57
Notice: Use of undefined constant base - assumed 'base' in /var/www/demos/pms/pmslib.php on line 63
Notice: Use of undefined constant host - assumed 'host' in /var/www/demos/pms/pmslib.php on line 79
解决方案