• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

Having trouble connecting to mssql database with migrated code

I'm having to move my web site to a new Linux box, and code that previously worked for connect to my mssql database via PHP no longer works.  I've read that PHP 5.3 no longer supports mysql, so what do I do?  Any help appreciated.

previously working code looked something like this:

$connect = mssql_connect("192.168.100.18", "php", "holistic") or die ("couldn't
connect");

mssql_select_db('[PSI_DB_1]', $connect);

$query1 = mssql_query("SELECT     COUNT(LJOB) AS totaljobs
FROM         BBJTHEAD
WHERE     (CANCDATE IS NULL) AND (FINALSHIP IS NULL) AND (CLOSEDATE IS NULL) AND (COGSDATE IS NULL)  AND (DUEDATE < DATEADD(day, 30, GETDATE()))
 ");
0
kennmurrah
Asked:
kennmurrah
1 Solution
 
Julian HansenCommented:
I've read that PHP 5.3 no longer supports mysql,
I think you meant mssql not mysql ...
You can use this library
http://www.microsoft.com/en-us/download/details.aspx?id=20098
0
 
Lukasz ChmielewskiCommented:
Impossible for PHP > 5.3 to NOT work with mssql.
put
error_reporting(E_ALL);
to the top of the script to see what's wrong and post the output.
0
 
Ray PaseurCommented:
$connect = mssql_connect("192.168.100.18", "php", "holistic") or die ("couldn't connect");

couldn't connect is not much of an error message.  This might give you a better diagnostic:
http://php.net/manual/en/function.mssql-get-last-message.php
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Dave BaldwinFixer of ProblemsCommented:
Julian's link is correct for a Windows server.  On a Windows server, PHP 5.3+ Requires the Microsoft PHP SQL driver.  

For Linux, Microsoft has released a 64-bit ODBC driver.  http://www.microsoft.com/en-us/download/details.aspx?id=28160

Here is the mssql page http://us.php.net/manual/en/mssql.requirements.php telling that on Linux, you have to install and configure 'freetds'.  I have never successfully done that.  Here is a question where the asker successfully did and told us what he did(!!):  http://www.experts-exchange.com/Programming/Languages/C/Q_27424576.html#a37069701
0
 
kennmurrahAuthor Commented:
For those suggesting a different driver, can I ask how that needs to be installed?  And to DaveBaldwin, does that mean I can't do it without freeTDS?  

I'm not getting an error message, just not getting anything at all.
0
 
Dave BaldwinFixer of ProblemsCommented:
Yes, that means you can't do it without FreeTDS on Linux.  The PHP page I linked says that and the EE page shows how.  There isn't a direct MSSQL driver on Linux.  If you have 64-bit Linux, that Microsoft page lists an ODBC driver and which systems it works with.
0
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.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now