The biggest things to do are to make sure you have php built with mssql support 
and have it enabled. There are multiple ways of adding extensions to php so 
I'll try to cover them both. The first is to build your extensions as 
externally loaded modules and used to be the most common method, as such I'll 
start with it.

With external modules you will want to do two things. Find your php.ini file, 
usually located in /etc/php and possibly in another subdirectory denoting the 
version.

Inside the php.ini file you need to look for the following directive.

extension_dir = some_path;

This will tell you where your extensions are on the file system. It is usually 
/usr/lib/php/version or something similar. The next thing you can do is check 
this path for a file called mssql.so If this file doesn't exist the mssql 
module wasn't built and you'll need to recompile php. Remember this only 
applies if you buitl php with extneral modules.

If the files mssql.so does exist if your extension_dir path open the php.ini 
file back up and make sure that the next directive exists somewhere in the 
php.ini. Most extension directives will be at the bottom of the file, and in 
some distros they will be in sub directories. Again, I can't help with 
specifics for Fedora.

extension=mssql.so

If that line doesn't exist add it. Restart apache and then move on to testing.

The first thing to do is to check the apache or php logs for errors. Typically 
if an extension can't be loaded for any reason it will write an error to one of 
those two logs. By default apache will catch this error unless you've 
specifically told php to log to its own file. If you have an error here, you'll 
have to let us know so we can help you proceed. If there are no errors, 
continue with testing.

The remaining testing will apply to both modular extensions and built in 
extensions. The easiest method has already been posted in another message so 
I'll just gloss over it.

Create a file in your document root such as phpinfo.php and include the 
following code:

<?php phpinfo(); ?>

Load this page in your web browser. You'll get a lot of diagnostic information 
about php, the extensions, and it's configuration. You want to skip down to the 
section labedl MSSQL. If MSSQL is configured and working it should look 
something like this:

mssql
MSSQL Support   enabled
Active Persistent Links         0
Active Links    0
Library version         FreeTDS

Directive       Local Value     Master Value
mssql.allow_persistent  On      On
mssql.batchsize 0       0
mssql.charset   no value        no value
mssql.compatability_mode        Off     Off
mssql.connect_timeout   5       5
mssql.datetimeconvert   On      On
mssql.max_links Unlimited       Unlimited
mssql.max_persistent    Unlimited       Unlimited
mssql.max_procs Unlimited       Unlimited
mssql.min_error_severity        10      10
mssql.min_message_severity      10      10
mssql.secure_connection Off     Off
mssql.textlimit Server default  Server default
mssql.textsize  Server default  Server default
mssql.timeout   60      60

If this section is empty or non-existant then mssql support was not built 
during the compile of php and you'll have to start over. If it is present you 
can do more simple testing.

Create a new file with the following code, modified to match your setup.

<?php

$dbHost = "hostname";
$dbUser = "username";
$dbPass = "password";
$dbName = "database";


$db = mssql_connect( $dbHost, $dbUser, $dbPass )
  or die("Couldn't connect to database server.\n");
mssql_select_db( $dbName, $db)
  or die("Couldn't select database.\n");

mssql_close( $db )
  or die("Couldn't close database connection.\n";);

echo "All tests successful.\n";

?>

Now, those tests are just going to establish that you can connecto the server, 
select a database, and close a connection. If you get an error at any of those 
points you'll have a starting point. It can be tricky to connect to mssql from 
linux and you may need to change some of the settings in mssql to be 
successful. Also of note, we don't have any information about what version of 
php, or mssql you are trying to use so the help cannot be more specific. For 
example in the latest versions of mssql it is sometimes necessary to specifiy 
the hostname to mssql_connect as "hostname.1443" which is the host and port 
seperated by a . instead of a : or \ as worked with previous versions.

If you have more problems, please feel free to respond, but please also include 
more detailed information such as the php version, mssql version, windows 
version and the specific errors you are encountering. Also, be sure to check 
the logs on the windows box as that may lead you to the solution as well.

Kyle

On Thu, 06 Jul 2006 15:24:37 -0700, "Horalia Rodriguez" <[EMAIL PROTECTED]> 
wrote:

> Hi,
>
> Sebastian Smith suggested that I send an e-mail here to see if I could get 
> some help to resolve my issue. I�ll be very brief.
>
> I am trying to connect to a MSSQL server from a Fedora Core box through php. 
> I have already successfully installed freetds, but I can�t get php to work. I 
> have installed freetds several different ways to no avail. I believe that it 
> is installed correctly because I can connect to the MSSQL server from the 
> terminal window and run a query successfully. I have also tried installing 
> php using ./configure �with-mssql=�freetds-path with no success. Could 
> someone send me detailed instructions on how to do this? I�m very new to 
> Linux and have been struggling to get this working for the past month. I�ve 
> been dreaming about rpms, unixODBC, php code, you name it. I have reloaded 
> Fedora more times that I care to remember, so any suggestions will be 
> appreciated.
>
> 
>
> Thanks,
> 
> Horalia Rodriguez
> [EMAIL PROTECTED] 
> _______________________________________________
> RLUG mailing list
> [email protected]
> http://lists.rlug.org/mailman/listinfo/rlug
> 
> 


_______________________________________________
RLUG mailing list
[email protected]
http://lists.rlug.org/mailman/listinfo/rlug

Reply via email to