Skip to Content.
Sympa Menu

freetds - Re: [freetds] MS-SQL from Linux Server through PHP

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thomas, Christopher (LLU)" <cwthomas AT llu.edu>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] MS-SQL from Linux Server through PHP
  • Date: Sun, 30 Mar 2008 09:25:26 -0700

Hello,

That is good that you got tsql working. You know it isn't a FreeTDS issue and
it is a PHP issue. Why use use PHP4 when Ubuntu 6.10 came with PHP 5.1.6?
First thing to check is to see if the MSSQL PHP extension is loaded. Create a
page that calls phpinfo(). This page will list all the extensions loaded in
PHP. If MSSQL is not loaded, then you know what your problem is. If it is
loaded, try running your program without the @ signs. This suppresses error
messages. Since you are trying to debug your program, I think you want it to
be as verbose as possible. Also, try adding the db resource variable $myconn
to mssql_select_db(), making it the second parameter.

<rant>
I read the article you linked to and IMO it is not that good. The author uses
an RPM based Linux distro. Nothing wrong with that, but he makes you
uninstall things like apache and PHP, then manual re compile them. Not using
the rpm system at all except to uninstall stuff. This isn't all that great.
There is no reason to uninstall anything. Also, compiling from source instead
of using the rpm, you loose all the distro specific patches. Since FreeTDS
comes with a .spec file, you can compile it using rpmbuild. For PHP, just
make sure the PHP source package is installed and run phpize;./configure
-with-mssql;make;make install in the MSSQL PHP directory. Then you don't have
to re compile all of PHP. One of the reasons that the article might not be
good is that it is old. The author is working with real old versions of
FreeTDS, Apache, and PHP.
</rant>

Since you are running Ubuntu, a deb based distro, you might want to follow
some instructions more fitted for your environment. After a quick google
search, I found this -
http://ubuntuforums.org/showthread.php?p=2088358#post2088358 . doing a search
on mssql ububtu or freetds ubuntu will give you a good list of things.

I hope some of these things above help.


Chris

-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of H.S.Rai
Sent: Saturday, March 29, 2008 7:37 PM
To: freetds AT lists.ibiblio.org
Subject: [freetds] MS-SQL from Linux Server through PHP

On following this:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=920&lngWId=8

by doing:

./configure --with-tdsver=8.0
make
sudo make install

tsql -S 192.168.8.88 -U username

works fine,

I was able to have connection to MS-SQL using code like:

$myconn = @mssql_connect ($server,$user,$password);
if(!$myconn) { echo ("<br>Can't connect MS SQL Server,"); exit();}
if(!@mssql_select_db($database))
{ echo "CanĀ“t connect Database"; exit();}
/*** Succesful Connection ***/

But following line gave error:

$sql = "SELECT * FROM tbl_AP";
$res = mssql_query($sql,$myconn); // Line ID 123: Give error

You selected file a.php to download. If I comment line ID 123 above,
php works fine, but with that line there it behave like PHP is not
working with Webserver. The result is same $res =
@mssql_query($sql,$myconn); i.e with symbol "@" used.

I am using PHP4 on Ubuntu 6.10 and MS SQL 2000 server.

Please help.

Thanks!

--
H.S.Rai
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page