Solved

PHP -  connect to another database

Posted on 2013-05-24
10
302 Views
Last Modified: 2013-05-27
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??
0
Comment
Question by:Camillia
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 6

Assisted Solution

by:RaithZ
RaithZ earned 125 total points
ID: 39194861
Are you trying to connect to someone else's phpmyadmin or have your php code connect to a database on another machine?

If its the later, then you will need them to give you the host to connect to, and put that in the code. You wouldn't connect to phpmyadmin with your php code, you would connect directly to the database.
0
 
LVL 10

Assisted Solution

by:JEaston
JEaston earned 125 total points
ID: 39194883
To the best of my knowledge a local install of phpMyAdmin can connect to any mySQL server.  However, many hosting company's block the ports that would be required to connect.  It makes the database more secure!

However, if you unblock the ports or whitelist your IP address then it should be possible to manage a remote mySQL install using a local phpMyAdmin install.
0
 
LVL 6

Expert Comment

by:RaithZ
ID: 39194905
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).
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39195171
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.
0
 
LVL 7

Author Comment

by:Camillia
ID: 39195474
thanks, guys. Let me read
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Author Comment

by:Camillia
ID: 39195729
>>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?
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 125 total points
ID: 39195774
IP address is fine for the host.  You do need the correct login info for it.  Unless it has been setup intentionally, there is no reason to think the remote database will have the same login as the local one.
0
 
LVL 7

Author Comment

by:Camillia
ID: 39195780
yes, i have the login/pwd to the database as well. I'll try it.
0
 
LVL 15

Assisted Solution

by:Jagadishwor Dulal
Jagadishwor Dulal earned 125 total points
ID: 39196246
I think you connect to mysql database not a phpmyadmin?? Can you access phpmyadmin in browser using  https://www.mysite.com/phpmyadmin/
0
 
LVL 7

Author Comment

by:Camillia
ID: 39196553
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now