How to connect mysql with difference server
If my all file is in 192.168.0.100 and mysql server is 192.168.0.200
I got Error "sorry, could not load your data, please try again later" when try it.
If bote all file and database is in same server , It run correct.

<?php
class DBConnection{
     function getConnection(){
     //localhost/amarokuser/amarokpasswd
         mysql_connect("192.168.0.200","root","") OR
     die("Could not connect: " . mysql_error());
   //amarokdb
         mysql_select_db("jqcalendar") OR
             die("Could not select database: " . mysql_error());
      }
}
?>

Recommended Answers

All 9 Replies

Probably you do not have access rights for the user "root" from an outside address. Login to 192.168.0.200 and check the permissions for the mysql user root.

You need to add a user to mysql for outside access and give it privledges to access the database jqcalendar. I would suggest using a different user than root and only giving access to the database you need to update. In your case I suggest the user name should be something like:
jqcaldb@192.168.0.100

But it can be any name you want as long as the ipaddress you are coming from is included.

@smantscheff : I'm sorry. I Just did example for user root.
@rch1231 : I had do that already. But it error "sorry, could not load your data, please try again later"
For this qcaldb@192.168.0.100 it cannot run correct for jqcalendar's table but other table i can got it in same user

Example table "user" i used user "qcaldb" and run php script from 192.168.0.100 connect to mysql 192.168.0.200 i can got user data all and when i used phpMyAdmin with same user to access to table jqcalendar from 192.168.0.100 result no problem
but when run wdCalender Script page (sample.php) i got error. also no problem when apache and mysql is in same server. What did i missing.
......
I forgot it ... When I use Desktop PC with Windows XP and use apache with servername localhost and IP 192.168.0.50 and connect to mysql server 192.168.0.200 it run correct too.
But if use Web server 192.168.0.100 connect to 192.168.0.200 it error
with my user is admin@% (Mean allow all) That Right?


Sorry for my bad Endlish.

@smantscheff : I'm sorry. I Just did example for user root.
@rch1231 : I had do that already. But it error "sorry, could not load your data, please try again later"
For this qcaldb@192.168.0.100 it cannot run correct for jqcalendar's table but other table i can got it in same user

Example table "user" i used user "qcaldb" and run php script from 192.168.0.100 connect to mysql 192.168.0.200 i can got user data all and when i used phpMyAdmin with same user to access to table jqcalendar from 192.168.0.100 result no problem
but when run wdCalender Script page (sample.php) i got error. also no problem when apache and mysql is in same server. What did i missing.
......
I forgot it ... When I use Desktop PC with Windows XP and use apache with servername localhost and IP 192.168.0.50 and connect to mysql server 192.168.0.200 it run correct too.
But if use Web server 192.168.0.100 connect to 192.168.0.200 it error
with my user is admin@% (Mean allow all) That Right?


Sorry for my bad Endlish.

More in formation
About grant user i have to do this
grant all privileges on *.* to admin@'%';
flush privileges;

sorry, could not load your data, please try again later

This is not a mysql error message. Where does it come from?
Can you connect to 192.168.0.200 from a mysql client at your workstation with the given username? And didn't you forget the password?

Are all of the servers in the same subnet and local to each other? If you have phpmyadmin then lyou should be able to look at the users table and see what users have privledges to what tables. double check your settings and do a tracert just to make sure you are following the path between servers y0ou think you are.

First i throught that about mysql connect with difference server problem but i can connect with command mysql -u -p and i can use phpMyAdmin to connect to it with client webserver.

also
I can solve it already. I put this script to get about ajax error.

$(document).ajaxError(function(e, xhr, settings, exception) { 
	alert('error in: ' + settings.url + ' \n'+'error:\n' + xhr.responseText ); 
});

It is a problem with json_encode() function in datafeed.php (wdCalendar)
That will be include in PHP5.2 up. Then I try to update my php to PHP5.3 ,It solve a problem.
After that if PHP is version 5.3 . I got new error about date_default_timezone_set

date_default_timezone_set('Asia/Bangkok');

I fix it with this in my timezone. I put it in dbconfig.php (wdCalendar)

Thank you all for every help. ู^^

First i throught that about mysql connect with difference server problem but i can connect with command mysql -u -p and i can use phpMyAdmin to connect to it with client webserver.

also
I can solve it already. I put this script to get about ajax error.

$(document).ajaxError(function(e, xhr, settings, exception) { 
	alert('error in: ' + settings.url + ' \n'+'error:\n' + xhr.responseText ); 
});

It is a problem with json_encode() function in datafeed.php (wdCalendar)
That will be include in PHP5.2 up. Then I try to update my php to PHP5.3 ,It solve a problem.
After that if PHP is version 5.3 . I got new error about date_default_timezone_set

date_default_timezone_set('Asia/Bangkok');

I fix it with this in my timezone. I put it in dbconfig.php (wdCalendar)

Thank you all for every help. ู^^

Hello neopalm, even after upgrading from php 5.2 to php 5.3 , the error persist, Can you give me any other suggestions for this ?

And one more thing is i am able to add the details to the database but only the month view is not showing up.

Never mind, some problem was there in datafeed.php
Everything is good as of now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.