NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Can't connect to database


Joined: 16 Mar 2008
Posts: 1
Reply with quote
I've written some php code to connect to a mysql database, which is as follows:

Code:
   function ConnectToDatabase(){
   
   global $hostname, $databaseName, $username, $password;   
   
   
   //create a connection to MySQL server
   $connection = mysql_connect($hostname,$username,$password) or
      die('Failed to connect to MySQL server. ' . mysql_error() .'<br />');
    
     //select the database
    mysql_select_db($databaseName, $connection) or
      die('Failed to connect to the database. ' . mysql_error());
    
     return $connection;
   
   }


This code works on a php webserver, but will not work when being run locally though the debugger in NuSphere.

It will time out and give an error message about not being able to connect 10060.

The firewall is completly open for outgoing connections.

Anyone have any ideas about how to setup the debugger to be able to connect to external databases?
View user's profileFind all posts by gunner_uk2000Send private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
I'm not sure what you're trying to achieve. If you debug on the remote server (in-place), your script would have an access to the database becuase it's on the same machine with database. If you debug scripts on your development machine, database is remote and you need to make it accessible.:
1) First of all, making database running on a public (remote) server accessible to your machine means you'd need to open database port on the server (3306 by default). Normally it's not what you want because it will weaken your server security.
2) You may consider accessing to your database with ssh tunnel like below:
ssh.exe -L3306:localhost:3306 yoursshaccount@yourwebserver
It requires access to your server with ssh. If you have it, just create the tunnel and work with mysql as if it was running on your local machine (hostname should be localhost). In this case if you already have a database running on your machine just stop it (or configure to use another port)
3) 3rd option is to run mysql on your development machine and have a copy of your server data. Many people prefer this way because it allows to freely work with data without possibility to affect public (life) server.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Can't connect to database
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic