Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

PHP - connect to another database

I'm new to PHP and I have the code/database working with WAMP on my local machine. I have a phpMyAdmin and my database is there...

Now, there's another phpMyAdmin that I have the URL for and our off-shore developers use that. I want to connect to a database on that phpMyAdmin. I tried below and it didnt work

1. I have the URL to that phpMySQL: https://www.mysite.com/phpmyadmin/
2. I put it in the code here
$dbhost = ' https://www.mysite.com/phpmyadmin/';
$dbuser = 'something';
$dbpass = 'something1';
$dbname = 'bdstaging';

Can I even connect to a phpMyadminthat's not local??
SOLUTION
Avatar of RaithZ
RaithZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes what JEaston said is correct, and to add to it, the db host wouldn't be the URL of the phpmyadmin, but the host name of the machine hosting the databases which may just be mysite.com. The port would probably need to be opened for you on the remote end (the off shore system).
Avatar of Dave Baldwin
To connect to another database server in phpMyAdmin, You have to duplicate the section in the 'config.inc.php' file that starts with $i++; and put in the info for the new host.  Don't include any of the 'pma' lines because they will only work on the local database.  Then the next time you start up phpMyAdmin, there will be a dropdown added to the login where you can select which database you want to connect to.  But... this will only work if you have a valid remote login to that database.  There is no 'generic' connection to a MySQL installation.
Avatar of Camillia

ASKER

thanks, guys. Let me read
>>it should be possible to manage a remote mySQL install using a local phpMyAdmin install. .

I can be on VPN and I have the server's IP address. I should put the IP address as the host name?

>>put in the info for the new host (From DaveBaldwin)...
 if I do this...i just put in the IP address, name of the remote database, etc?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes, i have the login/pwd to the database as well. I'll try it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, i want to connect to mySQl and yes, I can access https://www.mysite.com/phpmyadmin/ 

So, I'm going to try the IP address of the server with mySQL's userid/pwd and see if i can connect thru code.