Link to home
Start Free TrialLog in
Avatar of TunaMaxx
TunaMaxx

asked on

Connect to Win2K/MSDE database from Linux/Apache/mySQL/PHP box on intranet?

Hello,

  I'm looking for some insight on connecting to a MSDE database on Windows 2000 Server via a local Linux / Apache
/ PHP / mySQL box. I am comfortable with PHP / mySQL, but am very new to MSDE / SQL Server.

  I have created a small web app to help our production departments track work progress, etc. The problem is, as of now most information is entered twice; once for the original order / invoicing application, and the second time when much of the same data is duplicated manually into the web app. Needless to say, this is big waste of time, and a potential source for errors.

  All I want to do is be able to SELECT from the database on the Win2K server and then INSERT / UPDATE the mySQL db on the Linux box. I don't want to modify the extremely important data in the original application in any way. I'd have a hard time trying to justify how I murdered years worth of data (yes, we have backups!) tinkering away.

  There will never be more than 5 to 10 simultaneous connections to my web app, so the solution doesn't have to be the most robust, scalable, super-duper approach around. A simple, easy does it setup will work here as long as it can gaurantee no harm will be done to the MSDE database or the Win2K server.
 
  Some details:

Win2K Server:
  Fully updated / service pack'd
  SQL Server 2000 / MSDE
  Current database is from order / invoicing application.

Linux server:
  Dell PowerEdge 4200
  RedHat 9 (Shrike)
  Apache/2.0.40
  PHP Version 4.2.2

  Both machines are on the same subnet, and I have full physical and administrative access to each. Is this going to be a relatively simple thing to do, or am I way off base?
Avatar of TunaMaxx
TunaMaxx

ASKER

Thanks for the links. They are very helpful in pointing out the path to take.

However, I spent most of yesterday beating my head against the wall on a couple of things. Anyone have any first hand advice on this?

Thanks,

Tony
What problems do you have? I'm not LAMP programmer, but if it's related to MS SQL, I could help.
Sorry for the dealy in response. I had to putthe project onhold for a couple of days...

Here's where I am:

(1) Installed FreeTDS and it is able to connect to the MSSQL Server.
(2) Configured PHP with both mySQL and ODBC support.

I *think* what I am having a problem with is configuring the freeTDS libraries, but I'm not 100% sure. At this point, this is the error I receive trying to connect:

*************************************
Warning: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /home/path/msde_connect.php on line 3
*************************************

Here is the code I'm using (of course with the correct username, password, etc):

<?php
// connect to DSN MSSQL with a user and password
$connect = odbc_connect("DSN", "Username", "Password") or die
("couldn't connect");

odbc_exec($connect, "use DBname");

$result = odbc_exec($connect, "SELECT ID FROM tablename");

while(odbc_fetch_row($result)){
print(odbc_result($result, "tablename"));
}

odbc_free_result($result);
odbc_close($connect);
?>
ASKER CERTIFIED SOLUTION
Avatar of Rimvis
Rimvis
Flag of Lithuania 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