Skip to Content.
Sympa Menu

freetds - Re: FreeTDS or PHP Bug?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Steve Langasek <vorlon AT netexpress.net>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: FreeTDS or PHP Bug?
  • Date: Wed, 17 Jan 2001 10:04:26 -0600 (CST)


Hi Darryl,

On Wed, 17 Jan 2001, Darryl Friesen wrote:

> I'll get the particulars out of the way first: Digital Unix 4.0F, FreeTDS
> 0.51, Apache 1.3.12 and PHP/4.0.4pl1 (apache module).

> In my PHP script, my connection to the server (MSSQL 7.0) seems to get
> dropped after an INSERT, UPDATE, or DELETE. The INSERT/UPDATE/DELETE does
> work (the table is modified) but any subsequent queries (SELECT etc) will
> fail.

> The BUGS file mentions a possible (unconfirmed) bug with TDS7 and
> INSERT/UPDATE, so I tried compiling with both --with-tdsver=4.2 and
> --with-tdsver=7.0, but I get the same result.

Using two --with-tdsver options is unnecessary, as --with-tdsver is used to
select a default protocol for the library. Specifying both, you may have
ended up with 7.0 again as your protocol version, so you may want to try
compiling with --with-tdsver=4.2 to see if it makes a difference.

> I'm not sure whether it's FreeTDS or PHP that's the problem, but I thought
> I'd post a message here before I open a bug report with the PHP people.
> Any thoughts? I'd appreciate any help or suggestions. I've included my
> sample PHP script below (The first SELECT works, the INSERT works, but the
> second SELECT fails)

Have you tried this query with anything other than PHP? You might try
downloading sqsh and running your queries using its interactive interface...
this can help identify whether the bug is in PHP or in freetds.

If you want to experiment with different protocol versions on the fly, you can
set the TDSVER environmental variable before loading the mssql extension to
PHP. (This may mean setting it before you start Apache, if mssql is
built-in.) I don't know the PHP API currently supports switching the API
version from within your script. The Perl DBI code does, and this would be a
good feature to add to PHP if it isn't there yet. I should poke around inside
PHP (haven't started using freetds w/ PHP yet here) to see what, if anything,
should still be done..

HTH,
Steve Langasek
postmodern programmer

> <?php
> $dbh = mssql_connect("server","username","password");
>
> $query = mssql_query("SELECT * FROM Subjects", $dbh);
> if ($query) {
> print "First SELECT successful<BR>\n";
> } else {
> print "First SELECT failed<BR>\n";
> }
>
> $query = mssql_query("INSERT INTO Subjects (Code,Subject) VALUES ('test1',
> 'TEST 1')", $dbh);
>
> $query = mssql_query("SELECT * FROM Subjects", $dbh);
> if ($query) {
> print "Second SELECT successful<BR>\n";
> } else {
> print "Second SELECT failed<BR>\n";
> }
> ?>





Archive powered by MHonArc 2.6.24.

Top of Page