Solved

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

Posted on 2004-09-14
7
432 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:TunaMaxx
  • 3
  • 2
7 Comments
 
LVL 19

Expert Comment

by:Rimvis
ID: 12061874
0
 

Author Comment

by:TunaMaxx
ID: 12077889
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
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 12081833
What problems do you have? I'm not LAMP programmer, but if it's related to MS SQL, I could help.
0
 

Author Comment

by:TunaMaxx
ID: 12135766
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);
?>
0
 
LVL 19

Accepted Solution

by:
Rimvis earned 500 total points
ID: 12141786
Are you trying to connect using DSN? I don't think it's supported on Linux.

You should use ADO class for PHP

$db = ADONewConnection('odbc_mssql');
$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
$db->Connect($dsn,'userid','password');

http://phplens.com/phpeverywhere/node/view/9
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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Creating and Managing Databases with phpMyAdmin in cPanel.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

16 Experts available now in Live!

Get 1:1 Help Now