Skip to Content.
Sympa Menu

freetds - Re: [freetds] Query failing when following a insert

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Daniel Fazekas <fdsubs AT axelero.hu>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Query failing when following a insert
  • Date: Tue, 16 Dec 2003 02:31:36 +0100


On Dec 16, 2003, at 0:59, Chris Hettinger wrote:

Great - we have plenty of information to work from now, the good or bad news is that there's nothing seemingly wrong with your configuration and very similar setups are known to be working just fine.

PHP version: 4.3.1 (apache2filter)
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
FreeTDS : freetds-0.62.dev.20030805

The PHP and FreeTDS versions are both quite recent, although it might be worth trying a later PHP version as there's not a single recent release which didn't have fixes relating to the rather new support for --with-mssql.

We certainly had PHP 4.3.1 in the past successfully accessing a very similar database - MSSQL 2000 running on Windows 2000 Server.

You originally wrote MSSQL 7.0 instead of 2000 (8.0) so it's worth a confirmation: is this the actual configuration that you are experiencing the problem with? Even if the actual production server is going to run MSSQL 7.0, it helps a lot if you can reproduce the bug even with this copy of MSSQL 2000.

One thing I never even heard of is this unofficial ADOdb database abstraction library for PHP.
Google pointed me to http://php.weblogs.com/ADODB along with a forum post on the same site talking about a non-functioning ADOdb on Linux whereas the plain mssql_* functions worked properly.
This makes the poor thing the primary candidate for being the culprit. :)

Here's what I believe you are trying to do, using the mssql_* calls:

if (!mssql_select_db('Northwind', $conn)) exit("Can't select database.\n");

$res = mssql_query("INSERT INTO Categories (CategoryName, Description) ".
"VALUES ('test name', 'test description')", $conn);
if (!$res) exit("INSERT failed.\n");

$res = mssql_query("SELECT @@IDENTITY", $conn);
if (!$res) exit("SELECT failed.\n");

$id = reset(mssql_fetch_row($res));
if (is_numeric($id))
echo "Last inserted ID value: $id\n";
else
echo "Fetch_row failed.\n";

[ $conn should have the result of mssql_connect() or _pconnect, you can find an example for that in that previous test script of mine, and it's using the demo Northwind database which you might have removed already.. ]

This works fine for me. Check whether it's working properly for you too.
If it is, then do your best to break it. :) Use the same INSERT statement and SELECT you did via the ADOdb layer.

--
fds





Archive powered by MHonArc 2.6.24.

Top of Page