Question

I am working on a biometric system for user check in/out for my organization. the device installs its own webserver having mysql and apache. Its working properly and stores the fingerprints to its database table (MySQL).
I have installed WAMP server also on my system. both server are running simultaneously. the device webserver can be accessed through localhost:8080 and the wamp server can be accessed through localhost.
Now what i want to do is to create a php system in wamp server to manage the database of the device which in on the webserver of that device. but the problem is I have no idea how to connect my php system from wamp server (localhost) to the database of the device on its own server (localhost:8080)
(I wnat to use this approach because the webserver of that device do not have PHP, and i do not want to mess with it. the device should do whatever it wants on its own server, I want to fetch all check In/Out data from that server to my php application on wamp server)..
any help will be greatly appriciated...

Was it helpful?

Solution

For connecting to a Database you only need to know is in which port its running. a default MySQL installation would configure it to run on 3306. First find out port number for MySQL in webserver(device) and that will solve your case.

If you had installed device server first and it install MySQL, it would be running on 3306(if u didn't change it) then you install wamp, which also install MySQL again on 3306 port. This will be a problem, two mysql instance can't run on same port. so you either remove mysql from wamp server or change its port number.

Connecting to a mysql from php doesn't depend on server as long as you provide ip/domain and port. so your proper php script would be:

<?php 
   // we connect to localhost at port 3307
   $link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
   if (!$link) {
     die('Could not connect: ' . mysql_error());
   }
   echo 'Connected successfully';

For windows, If you want to know the port number of your local host on which Mysql is running you can use this query on MySQL Command line client --

 mysql> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+

1 row in set (0.00 sec)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top