Page 1 of 2
Error -> Connect to remote MySqlDatabase
Posted: Sun Dec 05, 2004 5:29 am
by asterinex
Hello,
I have a Mysql Database at a server with a lot of data in it.
Now I have another domain, but I want to access de DB at my other site to read the data. So I replaced Localhost with mydomain.
I used this line of code
$ie_conn = mysql_connect("
www.mydomain.com", "user","Password");
The Error
Warning: Access denied for user: '
user@d31A4C67E.kabel.telenet.be'
Anyone Knows a solution ?
Thanks
Posted: Sun Dec 05, 2004 8:07 am
by kettle_drum
Make sure that the user is allowed to login from a remote location - check the Host column in the User table in the mysql database. If it says 'localhost' then you need to change it to either % or the IP address of the second server. You might also want to just create a new user that is only allowed from the second server's IP and give it limited privledges.
Posted: Sun Dec 05, 2004 9:22 am
by asterinex
Thanks, but I cannot change Localhost on my Server . The Actual Idea is to write a small game in c++ that connects to the database to update Highscores ,......
Posted: Sun Dec 05, 2004 9:28 am
by timvw
you could put a little script on yoru server that accepts sql queries or so... and then call that script from whatever program that needs it..
Posted: Sun Dec 05, 2004 10:02 am
by asterinex
Thanks, Could you tell me a bit more about scripts.? What language is it ? Maybe you have an exemple or know a good site to find that info?
Posted: Sun Dec 05, 2004 10:21 am
by kettle_drum
Just a PHP script that takes a query as input, and then returns the results.
Code: Select all
if($_POST['uid']=='jkhsafib3d7'){ //do some kind of user check/login
$query = check_query($_POST['query']);
$result = mysql_query($query);
//print the results back to the user
}
Posted: Sun Dec 05, 2004 10:25 am
by asterinex
Thanks
Posted: Sun Dec 05, 2004 11:17 am
by asterinex
Thanks, But I need a communication between a client game c++ en mysql on the server in both ways.
Sending Query -> Updating records.
Receiving Result of Query -> Who´s online , or who is the best Highscore.
Posted: Sun Dec 05, 2004 11:20 am
by timvw
just plug libcurl into your c++ app.. and do your thing..... (or try to find a mysql server that allows external connections)
Posted: Sun Dec 05, 2004 11:21 am
by Benjamin
If you know C++ then PHP will be easy for you. Write some C++ code that posts data to a url on your server. Use a php script to update the database, and then return data back to your application in for form of an ini file or something.
Code: Select all
їwhos_online]
username
username2
username3
їhighestscores]
25112254
15224456
etc....
Posted: Sun Dec 05, 2004 11:23 am
by timvw
adodb package has a script.... server.php that does exactly this: accept query through get parameter, and then return resultset packaged as CSV string/file
or you are into xmlslow, have a look at soap etc :p
Posted: Sun Dec 05, 2004 12:48 pm
by kettle_drum
Just as a note: the little bit of code i wrote above does allow communication both way - to get results and insert data.
Posted: Sun Dec 05, 2004 12:52 pm
by Benjamin
You don't want your app remotely connecting to the database anyway, then anyone with a packet sniffer will have the username and password and could wreak havoc on it or create invalid entries, such as impossible high scores.
Posted: Sun Dec 05, 2004 3:00 pm
by asterinex
Thnanks,
So the best thing to do is to use POST & GET. Is also fast & stable enough to query with 500 users every minute ? and is it possible to retrieve Text fields of +- 256 Chars ?
Posted: Sun Dec 05, 2004 4:53 pm
by timvw
agtlewis wrote:You don't want your app remotely connecting to the database anyway, then anyone with a packet sniffer will have the username and password and could wreak havoc on it or create invalid entries, such as impossible high scores.
nobody said you have to do it unencrypted
both, methods (mysql lib and http - php proxy) can use SSL
invalid entries can always be made, it's just a matter on how hard you want to make it not to happen....