Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
using MSSQL with PHP [resolved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
lethe
n00b
n00b


Joined: 25 Jun 2002
Posts: 49

PostPosted: Thu Jan 25, 2007 11:15 pm    Post subject: using MSSQL with PHP [resolved] Reply with quote

So I need to make my PHP box connect to an MSSQL server. I just added mssql to my use flags and recompiled PHP (which installed freetds as well). Now it seems to have installed successfully:

Code:

 # php -m
[PHP Modules]
curl
date
dom
ftp
gd
libxml
mcrypt
mssql
mysql
openssl
pcntl
pcre
posix
readline
session
soap
sockets
standard
xml
zlib

[Zend Modules]



And I'm able to connect successfully to my server with
Code:
tsql -S server -U user -P pass
.

However when I call mssql_connect() in a php script, I get the error
Code:

Fatal error: Call to undefined function mssql_connect() in /home/user/public_html/mssqlphp.php on line 2


which seems to imply that it didn't install correctly. Can you help me fix it? All the documentation on the web for php/mssql seems to be for windows installations, with windows dlls and such, but I need it on my linux box. I'm running a 2.6 kernel, php version 5.1.6-pl6-gentoo. The SQL server is MSSQL 2000 (I think). Thanks!


Last edited by lethe on Tue Jan 30, 2007 7:10 pm; edited 2 times in total
Back to top
View user's profile Send private message
blommethomas
Apprentice
Apprentice


Joined: 16 Nov 2005
Posts: 285
Location: roeselare, belgium

PostPosted: Fri Jan 26, 2007 6:37 am    Post subject: Reply with quote

have you installed a wabserver, like Apache?
_________________
IK BEN GEK
Back to top
View user's profile Send private message
lethe
n00b
n00b


Joined: 25 Jun 2002
Posts: 49

PostPosted: Fri Jan 26, 2007 4:49 pm    Post subject: Reply with quote

blommethomas wrote:
have you installed a wabserver, like Apache?

Yes. I'm trying to get php to load the mssql extension. I have no trouble getting mod_php working with apache, but thanks.
Back to top
View user's profile Send private message
keyson
l33t
l33t


Joined: 10 Jun 2003
Posts: 830
Location: Sweden

PostPosted: Fri Jan 26, 2007 5:07 pm    Post subject: Reply with quote

This may be something for you.

http://www.linuxjournal.com/article/6636
Back to top
View user's profile Send private message
lethe
n00b
n00b


Joined: 25 Jun 2002
Posts: 49

PostPosted: Tue Jan 30, 2007 12:13 am    Post subject: Reply with quote

keyson wrote:
This may be something for you.

http://www.linuxjournal.com/article/6636


Hi keyson. I'd actually seen that page already when googling about my problem. That article describes how to install the software from a tarball, but of course as a gentoo user, I really ought to install it with emerge.

So my phpinfo() page claims that the configure line used to compile php is
Code:

'./configure' '/usr/lib/php5/share/config.site' '/usr/lib/php5/etc/config.site'


It doesn't make any mention of options like apxs=/usr/apache or --with-mysql=/usr/mysql, which would be there if I'd configured and compiled manually from the tarball. This suggests to me that emerge does something nonstandard with php configuration. There is no file /usr/lib/php5/etc/config.site, so I'm not really sure what it does.

So I simply can't tell whether emerge is actually compiling php correctly. If so, why isn't this extension available to me? If not, then is there a bug in gentoo's php ebuild?
Back to top
View user's profile Send private message
keyson
l33t
l33t


Joined: 10 Jun 2003
Posts: 830
Location: Sweden

PostPosted: Tue Jan 30, 2007 8:01 am    Post subject: Reply with quote

Yes the configure seems odd.

Have you tried to install FreeTDS from portage with mssql use flag,
and compiled php with mssql use flag ?

Then check the mssql part of the phpinfo().

Checking the changelog on freetds it looks like it should run with php.

You may have to edit the mssql part of the php.ini.

I don't use mssql. But I could fix something up to test it.

You may use the odbc USE flag also.
Back to top
View user's profile Send private message
lethe
n00b
n00b


Joined: 25 Jun 2002
Posts: 49

PostPosted: Tue Jan 30, 2007 5:21 pm    Post subject: Reply with quote

keyson wrote:
Yes the configure seems odd.

Have you tried to install FreeTDS from portage with mssql use flag,
and compiled php with mssql use flag ?

Then check the mssql part of the phpinfo().

Checking the changelog on freetds it looks like it should run with php.

You may have to edit the mssql part of the php.ini.

I don't use mssql. But I could fix something up to test it.

You may use the odbc USE flag also.


Yes, I added mssql to my /etc/make.conf, then re-emerged php. Because of the change in use flags, freetds was also emerged. Observe:

Code:

 # equery uses php
[ Searching for packages matching php... ]
[ Colour Code : set unset ]
[ Legend        : Left column  (U) - USE flags from make.conf                     ]
[                  : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-lang/php-5.1.6-r6 ]
 U I
 - - adabas              : Adds support for the Adabas database engine
....
 + + mssql               : Adds support for Microsoft SQL Server database
....


Code:

 # equery uses freetds
[ Searching for packages matching freetds... ]
[ Colour Code : set unset ]
[ Legend        : Left column  (U) - USE flags from make.conf                     ]
[                  : Right column (I) - USE flags packages was installed with ]
[ Found these USE variables for dev-db/freetds-0.62.3 ]
 U I
 + + mssql : Adds support for Microsoft SQL Server database
 + - odbc  : Adds ODBC Support (Open DataBase Connectivity)


After that didn't work, I then added odbc to my use flags and recompiled again and then tried again, this time with the odbc_connect function instead of the mssql_connect function. Same result, undefined function error.

Neither mssql nor odbc is mentioned in my phpinfo() output, although both are listed in the php -m command line option.

I have not added anything to my php.ini. The php mssql documentation says I should add
Code:
extension=php_mssql.dll
to my php.ini, but that seems to be windows specific. I am running gentoo. Is there a different specification I should add? Something like
Code:
extension=php_mssql.so
? But I searched for a file names mssql.so on my filesystem, didn't find anything.
Back to top
View user's profile Send private message
lethe
n00b
n00b


Joined: 25 Jun 2002
Posts: 49

PostPosted: Tue Jan 30, 2007 5:37 pm    Post subject: Reply with quote

lethe wrote:

I have not added anything to my php.ini. The php mssql documentation says I should add
Code:
extension=php_mssql.dll
to my php.ini, but that seems to be windows specific. I am running gentoo. Is there a different specification I should add? Something like
Code:
extension=php_mssql.so
? But I searched for a file names mssql.so on my filesystem, didn't find anything.


OK, I just went ahead and added that line to my php.ini, and I guess it works now!

Thanks for taking a moment to help me troubleshoot this, keyson! I guess it's resolved now.
Back to top
View user's profile Send private message
lethe
n00b
n00b


Joined: 25 Jun 2002
Posts: 49

PostPosted: Wed Jan 31, 2007 9:08 pm    Post subject: Reply with quote

I marked this post as resolved, and I guess I'll leave it that way, but I noticed something weird today.

My apache error log is reporting that PHP cannot find the mssql.so extension file. Thus adding it to php.ini is not what solved my problem. In fact, if I removed that line, then restart apache, I no longer get the error in my log and mssql still works. I don't know what changed from before, but I guess it works now, so I'll try not to care.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum