Jump to content
Larry Ullman's Book Forums

Ms Sql Server (Hush My Mouth) Question


Recommended Posts

That dark day is upon me. I knew it would eventually come but I was clipped from behind, never saw it coming. After becoming good friends with mySQL, this dark antagonist comes in the form of mssql server and how to access it, run procedures using my Microsoft un-savvy MAMP php MAMP 1.9.6 with php 5.3.5 (on a MAC).

 

I found a few clues in the php.ini file that 5.3.5 is at least aware of the existence of ms sql server. Here is an snippet:

--------------------------

;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
;
; ... or under UNIX:
;
 extension=msql.so
;
; Note that it should be the name of the module only; no directory information 
; needs to go here.  Specify the location of the extension with the
; extension_dir directive above.


; Extensions

;extension=apc.so

extension=imap.so
extension=yaz.so
extension=mcrypt.so
extension=gettext.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so

 

-------------------------------

There is also this:

--------------------------------

 

[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent).  -1 means no limit.
mssql.max_links = -1

; Minimum error severity to display.
mssql.min_error_severity = 10

 

----------------------------

You will note that I un-commented the "extension=msql.so" on the whim that this would somehow get me closer to giving my php understanding of commands like "mssql_connect($myServer, $myUser, $myPass)" but this did not happen.

 

My Project is not big and simply requires running a few stored procedures from MS SQL. I'm obviously missing something, perhaps a library supplement for php.

 

Any clue her will be greatly appreciated.

 

thanks

Chop

Link to comment
Share on other sites

I would start here: http://www.php.net/m...mssql.setup.php

 

You will need to have PHP installed with the right features. If PHP is installed on a Windows machine using WAMP (and probably XAMPP) the installer will automatically build PHP with the features you need. But if your server is running a different operating system it probably doesn't currently support accessing Microsoft databases. You will have to 're-make' PHP and specify which modules to include.

 

Once you have support for MSSQL installed, it's just a matter of using the different functions in PHP for accessing that database. If you understand MySQL, you shouldn't have any difficulty with MSSQL.

Link to comment
Share on other sites

Okay, thank you. I installed XAMPP hoping that it might have more support features than MAMP. However, it still doesn't seem to want to connect to a ms sql server.

 

1. Paul, you mentioned that I might have to "'re-make' PHP". Can you explain more on that?

 

2. The php.ini in XAMPP file does not contain a line with "mssql.so". This is why I think that something needs to be installed somewhere.

 

3. Someone mentioned installing a product called "freetds"??

 

Also, someone suggested I invest $35 in an ODBC driver such as the one here:

https://www.actualtech.com/buynow.php

 

saying that this will provide the connectivity.

 

I'm a little confused as to how all this relates to one another. How does PHP itself need to be modified and (if it is modified correctly - the necessary libraries etc,) do I still need an ODBC driver? OR if I have an ODBC driver, does PHP still need to be tweaked to work? I wish I had a better concept of how all it goes together. I Googled my brains out but I get bits and pieces that are hard to fit together.

 

FYI, here is the code I am using to try and connect with the server:

 

<?php
ini_set('display_errors', 1);// displaying errors = true
error_reporting(E_ALL);// show all types of errors
$myServer = "johndoe.siriusware.net";// not the real server name,un, or pw
$myUser = "myPass";
$myPass = "myPass";
$myDB = "SkiSwap";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
 or die("Couldn't connect to SQL Server on $myServer");//code dies here

 

 

CHOP

Link to comment
Share on other sites

Okay, thank you. I installed XAMPP hoping that it might have more support features than MAMP. However, it still doesn't seem to want to connect to a ms sql server.

 

Just to confirm, you're running a Mac and connecting to MS SQL server on another machine, correct?

 

1. Paul, you mentioned that I might have to "'re-make' PHP". Can you explain more on that?

 

It's a matter of configuring and building PHP. There are tutorials online for this, but it's not for the faint of heart.

 

2. The php.ini in XAMPP file does not contain a line with "mssql.so". This is why I think that something needs to be installed somewhere.

 

If PHP is running on a Mac, then it doesn't surprise me that there's no mention of mssql.so. More importantly, there's probably no mssql.so on your computer (you can search for it, to be certain).

 

Also, someone suggested I invest $35 in an ODBC driver such as the one here:

https://www.actualtech.com/buynow.php

 

saying that this will provide the connectivity.

 

Don't do that. You can actually just use PHP's ODBC driver. The ODBC driver is just a generic interface that works with many database applications. You can also use PDO ODBC, too.

 

FYI, here is the code I am using to try and connect with the server:

 

I appreciate you including as much information as possible, but the code isn't really relevant until you know you've got an extension that will work with MS SQL.

Link to comment
Share on other sites

I think the problem is the fact that I have a Macintosh. There's plenty of free support for Windows but have found nothing free and easy for the Mac. I have found many complex explanations of how to accomplish this but they all involve getting a ODBC driver and about 25 other steps which aren't easy to understand. There are no free drivers that I've found either. I went to Microsoft and only found drivers for Windows.

 

Even after contacting tech support at:

 

https://www.actualtech.com/buynow.php

 

to see if their solution would work, the representative gave the following reply:

----------------------------------

Hi Gary,

 

I'm going to pull some information together for you that hopefully will help you get connected using ODBC.

 

In the meantime, I have a couple of questions for you:

 

1. Is your PHP (local and hosted) built with the iODBC module (i.e. does the function phpinfo() include a section for iodbc)?

 

2. Are you using shared hosting, or do you have your own dedicated server?

 

Best regards,

 

Jonathan Monroe

Actual Technologies - ODBC for Mac OS X

support@actualtech.com

---------------------------------

 

I gave him the information a couple days ago but have not heard from him.

#1 NO

#2 SHARED HOSTING

 

 

 

"Don't do that. You can actually just use PHP's ODBC driver. The ODBC driver is just a generic interface that works with many database applications. You can also use PDO ODBC, too."

 

If anyone knows a link where I can simply get a free (above) driver, install it, and have it work with MAMP or XAMPP please let me know. I appreciate all the help here.

 

Chop

Link to comment
Share on other sites

Well, using a Mac to connect to an MS SQL Server is a fairly unique idea. I've never done it myself. It doesn't look like MAMP has ODBC built in, which means to get ODBC support on MAMP, you'll need to rebuild PHP. This is not for the faint of heart, so using a purchased option may be easier.

 

That being said, you answered the question about the hosting. Are you trying to connect from your Mac to MS SQL or will your hosted site connect to MS SQL? Or are you saying your shared hosting is on a Mac?

Link to comment
Share on other sites

I'm trying to create a sort of "intake form" for a client who will be running mssql from their server. So I need my Mac to write and test the code locally by connecting to a "test" mssql server that is already set up for this purpose. I have to talk to mssql instead of the usual mySQL. Ultimately the php code that I write will be running from a server that is on the client's site whom will also be hosting their own sql database. My other option ( I thought) was to test the code on a host where I already have an account - hoping that their php had the proper ODBC. However, though they provide php/mySQL services, they do not provide for connecting to a ms sql server. Only mySQL. I hope this makes sense!

 

Here is the latest response (FYI) from Actualtech (above):

 

Hi Gary,

 

I did a little investigation, and it looks as if neither MAMP nor XAMPP ship with the ODBC module included. The native version of Apache shipped with Mac OS X does include ODBC support, but MAMP and XAMPP do not.

 

I'm afraid that's going to preclude anything we can offer you. If you're able to use an Apache installation that includes iODBC, you would be able to use the PHP odbc_connect() functions with our "Actual SQL Server" driver to perform queries against your MS SQL Server database:

 

http://www.actualtech.com/phpsetup.php

 

 

thanks,

Chop

Link to comment
Share on other sites

Well, the easiest solution may just be to purchase cheap Windows hosting for a couple of months. Get one with PHP and MS SQL Server and it may only set you back $50 for 2-4 months, then you can drop it.

Link to comment
Share on other sites

The power of the dark side, Windows hosting, is something I can feel even with my Mac and mySQl server turned off. But I will try some of these other options. The 'Abigail' proposal is interesting and will try that first.

 

I think I've about rounded up all the information I need about this topic... just a matter of deciding a course of action. Thank you all for your assistance - as always it was so helpful to me.

 

ciao fro now,

Chop

Link to comment
Share on other sites

 Share

×
×
  • Create New...