How can I connect to Sage from PHP in Linux?

Sage Version is SageLine50v10
Who is Participating?
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
Ah. Are you intending to write data back? I must admit, I never really played with their ODBC route as I believe it to be read-only. But that was a LONG time ago.

If you have SageCover (or whatever it is now called), then maybe it is worth seeing if they have unixodbc compliant drivers. I doubt it.

Using a proxy is probably the only way to do it.

Or you could go IIS and PHP which is well supported now. I'm running 3 IIS7+FastCGI+PHP5.3 servers here quite happily. We have an old Retrieve 4GL app (now well over 12 years old and still going), but I convert the data to MS SQL (over 7.5 million rows - 2.5GB) nightly.

Now there's a thought.

If you have a tool to extract ALL the data to an SQL DB (mySQL for example) - even using PHP on the Sage PC side (no webserver, just straight PHP scripts), then you could quickly sync the data.

Raja Jegan RSQL Server DBA & ArchitectCommented:
Try creating a DSN First for your Sage server..
And then you can do something like the one below to connect

$database = "DSN";
if (!$db = @odbc_connect($database,"user","pass")) {
   echo "Could not connect to $database!\n";

More info here:
skmanjiAuthor Commented:
Sage resides on a Windows PC - there is no Linux version of Sage. I want to connect from a Linux PC - so where do I put the IP of the windows PC?

What you are suggesting may work for a windows version of PHP which is on the same machine as the Sage. But thats not whats required :(
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Richard QuadlingSenior Software DeveloperCommented:

Sage Line 50 is a peer-to-peer, windows based entry level accounting system. Not client/server. No centralized service. At the time (about 6 years ago), Line 100 was the same; peer-to-peer.


Line 50 does have an import/export facility so you can produces CSV style files and import them into your linux box.

I used to develop an EPOS system which could interact with Sage Line 50 and Line 100. It was written in Sage's Retrieve 4GL. It was DOS based, but ran under the Sage's Line 100 Windows runtime quite happily.

I would NOT recommend talking directly to the Line 50 DB as it is not a normalised DB and you have to know WAY too much.

What data are you wanting to import/export.
Richard QuadlingSenior Software DeveloperCommented:
The EPOS system would read Stock and Customer records and provide files for Stock transactions and Sales/Nominal transactions. It was just a case of running the imports and exports in the right sequence and all was well.
skmanjiAuthor Commented:
We can already read from a Sage DB via ODBC drivers using Visual Foxpro (because the VFP App resides on the same PC as a Sage Installation.)

However we are moving away from VFP to browser based apps using PHP/Linux. But its not (yet) possible to wean Accounts from Sage - so we need to be able to access the Sage DB from our remote PHP Apps to get data for reporting purposes. Currently we have to use VFP Apps.

A solution would be to have a windows-based web server on the Sage PC and use that as a "bridge" so that any app can call the windows web server and that in turn will call the Sage via a local ODBC - but you can see its getting a bit convoluted. An ideal solution would be to access the Sage directly via ODBC from any remote location.
skmanjiAuthor Commented:
"...quickly sync the data." Good idea. Thx.
skmanjiAuthor Commented:
The solution wasnt what I wanted ideally - but a reasonable compromise. It seems what I want isnt available.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.