Skip to Content.
Sympa Menu

freetds - Re: PHP, FreeTDS and SQL Server 7

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "David Derr" <davidderr AT britsys.net>
  • To: <freetds AT franklin.oit.unc.edu>
  • Subject: Re: PHP, FreeTDS and SQL Server 7
  • Date: Sat, 20 Oct 2001 14:41:51 -0400


Here is the my shell, including the contents of the file in
/tmp/tdsconfig.log after running the script with php as a cgi ( no seg
faults this time :) )

[root php_cgi]# ./index.php
DB-Library: Login incorrect.
X-Powered-By: PHP/4.0.6
Content-type: text/html

ConnectID: <br>
<br>
<b>Warning</b>: 0 is not a Sybase link index in <b>./index.php</b> on
line <b>7</b><br> <br>
<b>Warning</b>: 0 is not a Sybase result index in <b>./index.php</b> on
line <b>9</b><br> <br>
<b>Warning</b>: 0 is not a Sybase link index in <b>./index.php</b> on
line <b>14</b><br> hello dave

[root php_cgi]# more /tmp/tdsconfig.log
2001-10-20 14:29:18 Attempting to read conf file
2001-10-20 14:29:18 Found conf file in
/usr/local/freetds/etc/freetds.conf reading sections 2001-10-20 14:29:18
Found matching section 2001-10-20 14:29:18 Found matching section
2001-10-20 14:29:18 Found host entry xxx.xx.xx.xxx 2001-10-20 14:29:18
IP addr is xxx.xx.xx.xxx

[root php_cgi]#


I x'ed out the ip (sorry, it is my company's server) but it was the
correct ip address set in the freetds.conf file.

David Derr
Developer - Miles Media Group
david.derr AT milesmedia.com

-----Original Message-----
From: bounce-freetds-137737 AT franklin.oit.unc.edu
[mailto:bounce-freetds-137737 AT franklin.oit.unc.edu] On Behalf Of Brian
Bruns
Sent: Friday, October 19, 2001 2:47 PM
To: TDS Development Group
Subject: [freetds] Re: PHP, FreeTDS and SQL Server 7


Ok,

Something is going wrong in the lookup of the server in the interfaces
file. I'll send you a new copy of config.c offline, copy it over
src/tds/config.c, compile, and run with it. It will create a log file
/tmp/tdsconfig.log...Post that file.

Brian

On Fri, 19 Oct 2001, David Derr wrote:

> Here is what I got by running the script in gdb. I am not exactly
> sure what is valuable besides the stack trace so here is my shell
> output for the whole thing ( not too long :) )
>
> [root bin]# gdb php
> GNU gdb 19991004
> Copyright 1998 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and
> you are welcome to change it and/or distribute copies of it under
> certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for
> details.
> This GDB was configured as "i386-redhat-linux"...
> (gdb) run /usr/local/apache_test/htdocs/index.php
> Starting program: /usr/local/php_cgi/bin/php
> /usr/local/apache_test/htdocs/index.php
>
> Program received signal SIGSEGV, Segmentation fault. 0x4016e81a in
> inet_aton (cp=0x0, addr=0xbfffe530) at inet_addr.c:119
> 119 inet_addr.c: No such file or directory.
> (gdb) where
> #0 0x4016e81a in inet_aton (cp=0x0, addr=0xbfffe530) at
> inet_addr.c:119 #1 0x4016e953 in inet_addr (cp=0x0) at inet_addr.c:85

> #2 0x40032c27 in tds_connect (login=0x816d398) at login.c:161 #3
> 0x4002bb99 in tdsdbopen (login=0x816d388, server=0x816dbc4 "mmg") at
> dblib.c:444 #4 0x80b238c in php_sybase_do_connect (ht=3,
> return_value=0x816d374, this_ptr=0x0, return_value_used=1,
> persistent=0)
> at php_sybase_db.c:471
> #5 0x80b248e in php_if_sybase_connect (ht=3, return_value=0x816d374,
> this_ptr=0x0, return_value_used=1) at php_sybase_db.c:518 #6
> 0x80ee306 in execute (op_array=0x81686ec) at ./zend_execute.c:1504 #7

> 0x80c7c6d in zend_execute_scripts (type=8, file_count=3) at zend.c:752
> #8 0x805fe58 in php_execute_script (primary_file=0xbffffb24) at
> main.c:1206
> #9 0x805e671 in main (argc=2, argv=0xbffffb84) at cgi_main.c:718
> (gdb) exit
> Undefined command: "exit". Try "help".
> (gdb) quit
> The program is running. Exit anyway? (y or n) y
> [root bin]#
>
>
> David Derr
> Developer - Miles Media Group
> david.derr AT milesmedia.com
>
>
> -----Original Message-----
> From: bounce-freetds-137737 AT franklin.oit.unc.edu
> [mailto:bounce-freetds-137737 AT franklin.oit.unc.edu] On Behalf Of Brian
> Bruns
> Sent: Friday, October 19, 2001 10:25 AM
> To: TDS Development Group
> Subject: [freetds] Re: PHP, FreeTDS and SQL Server 7
>
>
> Ok wasn't very hopeful about that answer, but I had to give it a try.
> Let's find out where it is crashing (this gets a bit more complex).
>
> first compile PHP without apache (aka cgi mode) and then run your
> script in gdb, such as:
>
> $ gdb php
> ...
>
> (gdb) run myscript.php
> .
> core dump
> .
> (gdb) where
> .
> stack trace
> .
> (gdb) exit
>
> And then send along the stack trace that is printed.
>
>
> On Fri, 19 Oct 2001, David Derr wrote:
>
> > After moving the conf file to a different name:
> > [root etc]# ll
> > total 4
> > -rw-r--r-- 1 root root 2478 Oct 18 12:30
> zzz_freetds.conf
> >
> > And restarting apache...
> >
> > I still get a segmentation fault:
> > [Fri Oct 19 09:15:37 2001] [notice] child pid 28828 exit signal
> > Segmentation fault (11)
> >
> > David Derr
> > Developer - Miles Media Group
> > david.derr AT milesmedia.com
> >
> >
> >
> > -----Original Message-----
> > From: bounce-freetds-137737 AT franklin.oit.unc.edu
> > [mailto:bounce-freetds-137737 AT franklin.oit.unc.edu] On Behalf Of
> > Brian
>
> > Bruns
> > Sent: Friday, October 19, 2001 8:25 AM
> > To: TDS Development Group
> > Subject: [freetds] Re: PHP, FreeTDS and SQL Server 7
> >
> >
> > Ok this may take a bit of leg work to solve, the big change from
> > 0.51
> > to 0.52 was the freetds.conf file. If you are still using the
> > interfaces file then move /usr/local/freetds/etc/freetd.conf to
> > another name and see if the behaviour changes.
> >
> > Brian
> >
> > On Thu, 18 Oct 2001, David Derr wrote:
> >
> > > Brian,
> > >
> > > I am not sure what changed between 0.51 and the later versions,
> > > but when I tried 0.52 and 0.53pre1 I get seg faults on the apache
> > > child when I try to make a database connection. My system is
> > > RedHat 6.2 connection to a Win NT Server running SQL7.
> > >
> > > Obviously I have not had a chance to test the configuration with
> > > these
> >
> > > later versions because of the seg faults ([Thu Oct 18 22:03:12
> > > 2001] [notice] child pid 28386 exit signal Segmentation fault
> > > (11)). Can you see anything I am doing wrong?
> > >
> > > Here is my build script:
> > >
> > > All done as root...
> > > FREE TDS 0.53
> > > /configure --prefix=/usr/local/freetds --with-tdsver=4.2
> > > --enable-dbmfix gmake make install
> > >
> > > edit /etc/profile adding:
> > > export SYBASE=/usr/local/freetds
> > >
> > > Add to /etc/ld.so.conf:
> > > /usr/local/freetds/lib
> > > Run ldconfig so that the libraries will be found by the linker
> > >
> > >
> > > APACHE 1.3.14 (the following configuration options assume that php

> > > and
> >
> > > apache are in parallel directories) /configure
> > > --prefix=/usr/local/apache_test
> > >
> > >
> > > PHP 4.0.6
> > > /configure --with-mysql --with-apache=../apache_1.3.14
> > > --enable-track-vars --with-mssql=/usr/local/freetds
> > > --with-sybase=/usr/local/freetds
> > > --with-config-file-path=/usr/local/apache_test/conf
> > > make
> > > make install
> > >
> > >
> > > APACHE 1.3.14
> > > /configure --prefix=/usr/local/apache_test
> > > --activate-module=src/modules/php4/libphp4.a
> > > make
> > > make install
> > >
> > > Also add the above to the startup script that starts the web
> > > server. SYBASE=/usr/local/freetds
> > >
> > > Thanks,
> > > David Derr
> > >
> > > -----Original Message-----
> > > From: bounce-freetds-137737 AT franklin.oit.unc.edu
> > > [mailto:bounce-freetds-137737 AT franklin.oit.unc.edu] On Behalf Of
> > > Brian
> >
> > > Bruns
> > > Sent: Thursday, October 18, 2001 12:46 PM
> > > To: TDS Development Group
> > > Subject: [freetds] Re: PHP, FreeTDS and SQL Server 7
> > >
> > >
> > > There is a bug in 0.52 regarding the ip lookup that affects some
> > > platforms. It is fixed in either 0.53pre1 or the CVS version.
> > >
> > > Brian
> > >
> > > On Thu, 18 Oct 2001, David Derr wrote:
> > >
> > > > Hello. I am trying to use freetds in conjunction with php and
> > > > MS SQL Server 7. I have posted a couple quiestions to the php
> > > > mailing
> > list,
> > > > but have hit a wall there.
> > > >
> > > > I have included the reply I recieved to the first post and my
> > > > second post below. I believe I have a configuration problem
> > > > unrelated to
> > php
> > >
> > > > or the database because it seems freetds always wants to connect

> > > > to 255.255.255.255 port 0 and that is not what I had in the
> > > > interfaces file.
> > > >
> > > > Any help would be greatly appreciated. I am sooo close and I
> > > > really hope this solution will perform better than our existing
> > > > one which
> > is
> > > > using an ODBC bridge.
> > > >
> > > > Thanks!
> > > > David Derr
> > > >
> > > >
> > > > Posteded to the PHP General Mailing List...
> > > >
> > > > Thanks for you build record, that helped greatly, I think my
> > > > main
>
> > > > problem was using 0.52 instead of 0.51.
> > > >
> > > > No more seg faults now when I try to run my script, but I am
> > > > still not
> > >
> > > > getting a connection to the database, and I think the problem
> > > > may
> > > > be the fact the freetds is not finding any configuration
> information.
> > > > Here is the php script I am running:
> > > >
> > > > <? putenv("TDSDUMP=/usr/local/apache_test/logs/tds.log");
> > > >
> > > > $nDBConn = mssql_connect("mmg", "username", "passwd"); echo
> > > > "ConnectID: $nDBConn<br>\n";
> > > >
> > > > $nStmt = mssql_query("select * from david_test", $nDBConn);
> > > >
> > > > while ($aRow = mssql_fetch_array($nStmt)) {
> > > > echo $aRow["Name"];
> > > > echo "<p>\n";
> > > > }
> > > >
> > > > mssql_close($nDBConn);
> > > > echo "hello dave";
> > > > ?>
> > > >
> > > > And when this runs there are connection errors, but if I look in

> > > > the TDSDUMP file I specified at the beginning of the script I
> > > > see this (which is not the ip or port I specified in my
> > > > interfaces
> > > > file): 2001-10-17 09:39:24 Connecting addr 255.255.255.255 port
0
> > > >
> > > > Along with these errors in my Apache error log file:
> > > > connect: Network is unreachable
> > > > DB-Library: Login incorrect.
> > > >
> > > > Here is my interfaces file, located at /usr/local/freetds mmg
> > > > query tcp tds4.2 ip.of.db.server 1433
> > > >
> > > > And last, here is the value of the SYBASE env variable: [root
> > > > /root]# echo $SYBASE /usr/local/freetds
> > > >
> > > > Did you or anyone else run in to this problem? I looked in the
> > > > config
> > >
> > > > file to see if there was a path you could specify for the
> > > > interfaces file but found only an alternate method of
> > > > configuring freetds, so I
> >
> > > > renamed it to zzz_freetds.conf and still get the error message
> > saying
> > > > it is connecting to 255.255.255.255.
> > > >
> > > > Thanks again in advance for any help.
> > > >
> > > > David Derr
> > > > davidderr AT britsys.net
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: Nick Talbott [mailto:nickt AT powys.gov.uk]
> > > > Sent: Tuesday, October 16, 2001 11:45 AM
> > > > To: David Derr; php-general AT lists.php.net
> > > > Subject: Re: [PHP] FreeTDS and SQL Server 7
> > > >
> > > > On Tuesday 16 October 2001 4:18 pm, David Derr wrote:
> > > > > Hey all, I was reading an old article at php builder about
> > > > > conntecting to SQL Server 7 on a Windows machine from a Linux
> > > > > machine via FreeTDS.
> > > > > (http://www.phpbuilder.com/columns/alberto20000919.php3)
> > > > [snip]
> > > > >
> > > > > Has anyone had sucees in getting this to work? I will include

> > > > > my config and compile commands below as well as the php script

> > > > > that
> > is
> > > > > breaking things.
> > > > [snip]
> > > >
> > > > We have that working reliably with the exception that I have
> > > > used TDS protocol version 4.2 rather than 7.0 because I had read

> > > > that this was
> > > a
> > > > little less well developed, and 4.2 gives you all you need in
> > > > any
> > > case.
> > > >
> > > > We're using slightly different components: Apache 1.3.20, PHP
> > > > 4.0.6, FreeTDS 0.51 running on a Slackware 8.0 base (Linux
> > > > kernel 2.2.19
> > with
> > >
> > > > glibc
> > > > 2.2.3)
> > > >
> > > > I've attached an HTML file of our build record for this.
> > > >
> > > > The other thing to note is that this approach allows you to use
> > > > PHP's mssql_ calls, but only those that have direct sybase_
> > > > equivalents.
> > So
> > >
> > > > make sure you
> > > > check out which calls are common to both sets of functions and
> > > > don't
> > > try
> > > > calls that only exist in the mssql_ function list.
> > > >
> > > > Regards
> > > >
> > > > Nick Talbott, IT Policy and Strategy Manager, Powys County
Council
> > > > email: nickt AT powys.gov.uk
> > > > fax: 01597 824781
> > > > web: www.powys.gov.uk and www.powysweb.co.uk
> > > >
> > > >
> >
> >
> > ---
> > You are currently subscribed to freetds as:
> > [david.derr AT milesmedia.com] To unsubscribe, forward this message to
> > $subst('Email.Unsub')
> >
> >
> >
> >
> > ---
> > You are currently subscribed to freetds as: [camber AT ais.org] To
> > unsubscribe, forward this message to
> > $subst('Email.Unsub')
> >
>
>
> ---
> You are currently subscribed to freetds as:
> [david.derr AT milesmedia.com] To unsubscribe, forward this message to
> $subst('Email.Unsub')
>
>
>
>
> ---
> You are currently subscribed to freetds as: [camber AT ais.org] To
> unsubscribe, forward this message to
> $subst('Email.Unsub')
>


---
You are currently subscribed to freetds as: [david.derr AT milesmedia.com]
To unsubscribe, forward this message to
$subst('Email.Unsub')





Archive powered by MHonArc 2.6.24.

Top of Page