[SOLVED] How to connect to a remote database?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

[SOLVED] How to connect to a remote database?

Postby johansalllarsson » 08. July 2008 12:24

Hi,
Im trying to connect to a database on a server but i end up getting these errors:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'mydb.somehosting.com' (10060) in C:\xampp\htdocs\www\db_test.php on line 12
Could not connect: Can't connect to MySQL server on 'mydb.somehosting.com' (10060)

The script is valid and works (just not when i run the script from localhost), and here it is:
$link = mysql_connect("mydb.somehosting.com", "user", "mypassword") or die("Could not connect: " . mysql_error());
mysql_selectdb("db",$link) or die ("Can\'t use db: " . mysql_error());

Btw i disabled my firewall, my antivirus, still no good.
How can i resove this issue?
Last edited by johansalllarsson on 08. July 2008 14:38, edited 1 time in total.
johansalllarsson
 
Posts: 4
Joined: 08. July 2008 10:29

Postby Wiedmann » 08. July 2008 12:47

$link = mysql_connect("mydb.somehosting.com", "user", "mypassword") or die("Could not connect: " . mysql_error());

You are not using the MySQL server from XAMPP? Because this one is on "localhost".

And if you want use another DB server... Maybe this one don't allow external connections.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby johansalllarsson » 08. July 2008 13:01

Yea, i figured it might be something like that.

However i have another db server i need to connect to (not the xampp one). Since I can connect to this server via MS Excel and download whatever this must indicate that it allows external connections, but i get the same response: cant connect etc...

Any ideas?
johansalllarsson
 
Posts: 4
Joined: 08. July 2008 10:29

Postby Nobbie » 08. July 2008 13:17

>Since I can connect to this server via MS Excel

I didn't know that MS Excel can connect natively to a MySQL Database Server?

Are you sure, you are running a MySQL Server remote?
Nobbie
 
Posts: 8775
Joined: 09. March 2008 13:04

Postby johansalllarsson » 08. July 2008 13:31

Well i can connect via Office database connections .odc.

Im adding my ip to my hostingserver to see if i can connect to that again. This way ill allow external connections from my ip. So if this fails something must be wrong with the settings in xampp i guess. Takes an hour so its just to wait....

>Are you sure, you are running a MySQL Server remote?

Im sure i have a Mysql server on the hostingserver, on the other server ive just been told we have it so i cant say for sure.
johansalllarsson
 
Posts: 4
Joined: 08. July 2008 10:29

Postby johansalllarsson » 08. July 2008 14:36

It works now... I allowed external connections to the server.
johansalllarsson
 
Posts: 4
Joined: 08. July 2008 10:29


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 40 guests