visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
303 experts, 1181 registered users, 1626 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Databases :: MS SQL Server :: linux-to-SQL-Server : "connect failed" from PHP, while it works from isql...


By: FiatLink Belgium  Date: 06/04/2005 13:39:07  English Dutch  Points: 50 Status: Answered
Quality : Excellent
I use FreeTDS latest (0.61) compiled from source & configured manually
I am able to connect using the tsql provided client, and the freetds.conf is thus ok :

x@fintools:/usr/local/src/freetds-0.61$ tsql -Sbeboss -Uboss_read_only -Pxxx locale is "C" charset is "ANSI_X3.4-1968" 1> select count(*) from dbo.e_trade_contracten 2> go 108076 1> quit x@fintools:/usr/local/src/freetds-0.61$


BUT I'm unable to connect from the SAME server using the running Apache+PHP_module, with the SAME password and settings of course. It is supposed to use the same freetds.conf file...

Just in case, I bypassed that freetds.conf file by using the direct IP address and explicit 1433 port, to no avail.

I still get "connect failed" in the TDS error...

how strange ;-)

The very same set of connection settings work on a Windows box, of course with lib_mssql.dll in stead of FreeTDS.

It must have to do with FreeTDS itself, but as I don't get a crash/segfault/coredump, I can't diagnose... Any ideas ?
By: FiatLink Date: 07/04/2005 08:52:36 Dutch  Type : Comment
I followed the very clear instructions at http://lists.ibiblio.org/pipermail/freetds/2003q3/013836.html but I still get this strange behaviour :

- I'm able to connect directly to the SQL-Server using its name (so freetds.conf is used and OK) with the "tsql" tool
- I'm unable to connect via PHP and mssql_connect()
By: VGR Date: 07/04/2005 09:02:23 English  Type : Comment
Nice message, but reproducing data from "S.A. Tan , 02-Jul-2003 02:58" found on php.net at http://terra.di.fct.unl.pt/docs/php/function.mssql-connect.php.htm ;-)

Anyway, given the transient nature of data over Internet, I reproduce that newsgroup/mailinglist article hereafter.
[freetds] Suse 8.2 install
Samuel Luxford-Watts
freetds%40lists.ibiblio.org?Subject=%5Bfreetds%5D%20Suse%208.2%20install&In-Reply-To= slwatts at winckworths.co.uk

Fri Sep 12 12:06:55 EDT 2003

Ok I have finally cracked it and got my suse 8.2 linux machine running the standard apache, mod_php and MySQL rpm's shipped buy Suse to also be able to query a MS SQL 7.0 database using php and freeTDS without having to download and recompile the complete source of either apache or php and so keeping it as 'standard' as possible. I have to say most of the credit goes to <A HREF="http://lists.ibiblio.org/mailman/listinfo/freetds">aissam at yahoo.com</A> &lt;mailto:<A HREF="http://lists.ibiblio.org/mailman/listinfo/freetds">aissam at yahoo.com</A>&gt; who posted a comment on the php documentation site on how he got his Mandrake 9.1 install to work with freeTDS without re-comiling the whole of php. (the link is at the end). I dont suppose this can be added to the guide? Its taken me the best part of week to get this beast to work..... Given a fresh install of apache (1.3.27-41.i586), mod_php4 (4.3.1-52.i586) and mod_php4-core (4.3.1-52) also install mod_php4-devel package and from the src folder of the installation cd's manually install mod_php4-4.3.1-52.src.rpm. You are now ready to begin..... 1. # download the latest copy of freeTDS (I am using a devel snapshot of 0.62 but 0.61 also worked) 2. # follow the instructions for installing freeTDS but add the following two directives when you run ./configure --enable-msdblib --sysconfdir=/etc/freetds 3. # make 4. # make install 5. # vi /etc/freetds/freetds.conf and add a section for your server I had huge problems with the locales settings as my servers are all configured to use uk/british english hence I had to add the following /etc/freetds/locales.conf: [en_GB] date format = %d %m %y %I:%M%p language = British char set = iso_8859-1 do the usual checks using tsql to ensure all is working fine with freeTDS before continuing. 1. # cd to where the php src package was installed - by default mine installed in /usr/src/packages/SOURCES/php-4.3.1/ 2. # cd ./ext/mssql 3. # phpize if this works with no errors/warnings about include/headers (.h) skip the next three steps. 4. # mkdir /usr/share/include 5. # ln -s /usr/include/php /usr/share/include/php 6. # phpize again and you should now get build dates after each 'configuring for...' 7. # ./configure --with-mssql=/usr/local (or wherever you installed freeTDS to in the section above) 8. # make 9. # ./libtool --mode=link gcc -L/usr/local/lib -lsybdb -I. -I/usr/src/packages/SOURCE/php-4.3.1 -DEAPI -g -O2 -o php_mssql.la -avoid-aversion -module -rpath /usr/src/packages/SOURCES/php-4.3.1/ext/mssql/modules php_mssql.lo 10. check where your php extensions are held by looking at /etc/php.ini and looking for the extension_dir setting. substitute the detination path below with your one if its different 11. # cp .libs/php_mssql.so /usr/share/extensions/no-debug-non-zts-20020429/ 12. now edit your php.ini (/etc/php.ini) and add the following line within the extensions section: extension=php_mssql.so 13. stop apache if its already running: # /etc/init.d/apache stop 14. and start it again: # /etc/init.d/apache start et voila - you should now be in business! Check out http://uk.php.net/manual/en/printwn/function.mssql-connect.php as this has other helpful comments added to it. Hope this helps someone!! Sam -------------- Winckworth Sherwood Solicitors and Parliamentary Agents DX 148400 WESTMINSTER 5 : 35 Great Peter Street, London SW1P 3LR Telephone 020 7593 5000 Fax 020 7593 5099 Do something amazing! The firm is supporting a charitable bike ride through Vietnam and needs your help. For further information please visit <A HREF="http://www.vietnambikeride.org">http://www.vietnambikeride.org</A> -Confidentiality- This email message and any attachments are confidential; they may be subject to legal professional privilege and are intended for the named recipient only. If you are not the named recipient, please return the message and enclosures immediately and delete them from your system. -Caution- Before advice received only by email (whether by attachment or otherwise) may be relied on, the authenticity of the communication must be verified by means independent of email. -Regulation- The firm is regulated by the Law Society. -Partners- A list of partners is available for inspection at each office of the firm and on the firm's website at http://www.winckworths.co.uk

By: FiatLink Date: 07/04/2005 09:06:15 English  Type : Comment
Thanks for the support.

Here's what I see in php.err file :

[07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_connect in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_pconnect in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_close in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_select_db in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_query in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_free_result in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_get_last_message in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_num_rows in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_num_fields in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_fetch_field in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_fetch_row in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_fetch_array in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_fetch_object in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_data_seek in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_field_seek in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_result in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_min_error_severity in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Function registration failed - duplicate name - mssql_min_message_severity in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: mssql: Unable to register functions, unable to load in Unknown on line 0 [07-Apr-2005 09:05:52] PHP Warning: Unknown(): Invalid library (maybe not a PHP library) 'php_mssql.so' in Unknown on line 0

By: FiatLink Date: 07/04/2005 09:07:55 English  Type : Comment
I suppose that's because of the --with-sybase= --with-mssql= we've been told to put on www.php.net (putting both seemed odd to me, but I followed instructions)

I really don't understand the problem. I already installed FreeTDS into PHP on a FreeBSD with no issue whatsoever.
By: VGR Date: 07/04/2005 12:51:09 English  Type : Answer
I found two possible tracks to follow :

First, contrarily to www.php.net's documentation of the mssql extension :

To enable mssql in php 4.3.3 and above on linux/unix boxes, you must put this line in php.ini

extension=mssql.so


You don't need at all to specify this extension . In fact, doing so could make the load fail....

Then the two possible ideas :
1) environmental settings :

$wd=getenv('WINDIR'); $sess_osWin=($wd<>''); session_register('sess_osWin'); if (!$sess_osWin) { putenv('FREETDSCONF=/usr/local/etc/freetds.conf'); // std anyway ;-) putenv('TDSDUMP=/tmp/tds.log'); putenv('SYBASE=/usr/local/freetds'); // this may be your culprit putenv('TDSVER=42'); }



2) in case of a FreeTDS library upgrade :
Contrarily to the freetds.org documentation, ***even*** with TDSVER=42 (protocol level 4.2) which is < 5.0, you ***may need*** to use ':' in stead of ',' between servername/IP@ and port number !
By: FiatLink Date: 11/04/2005 09:32:09 English  Type : Comment
well seen, it was case (2) ...
f@#}.ing internet documentation, never up-to-date...

thanks !

Do register to be able to answer

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 12412.058830 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page