Skip to Content.
Sympa Menu

freetds - Re: Linux/FreeTDS/unixODBC/PHP Text fields

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Peter Harvey <pharvey AT codebydesign.com>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Linux/FreeTDS/unixODBC/PHP Text fields
  • Date: Tue, 29 Jan 2002 09:22:46 -0800


Here is a guess (just a guess). Looks like it could be a short coming in the FreeTDS ODBC Driver.

I wish I could look into it for you but I am too busy right now. <aaargh>

Peter


Andersen, Al wrote:

I've got a problem with using FreeTDS on my Linux server with unixODBC and
Apache/PHP. From my Linux box, I can make connections to my MSSQL 7.0
database on the NT server, and I can also retrieve data OK with ISQL. The
problem is that I can't retrieve TEXT data using Apache/PHP.

I'm familiar with this problem using Apache/PHP/ODBC on an NT 4.0 web
server. You have to set some PHP.INI variables to do things right. However,
on my Linux box, no matter what variables I set, unixODBC/TDS keeps bombing
out on me when I try to retrieve TEXT data, regardless whether it contains
apostrophe's or not. I don't have this problem with unixODBC/ODBC-Bridge
(well, at least not with *getting* the data).

Does anyone else have this problem? If not, could someone give me some
pointers as to what I might be doing wrong?

FreeTDS v0.53
PHP v4.1.1
unixODBC v2.1.1
Apache v1.3.22
SuSE v7.3 Professional

Here's the pertinent PHP.INI info:

magic_quotes_gpc = Off #MSSQL
magic_quotes_runtime = On #MSSQL
magic_quotes_sybase = On #MSSQL
odbc.defaultlrl = 131072 #128K

Here's how I make my connection/call to the MSSQL database from Linux
Apache/PHP:

$odbc_db = "ists"; # SQL Server database name
$odbc_dsn = "isec_sts"; # SYSTEM DSN name (unixODBC)
$odbc_server = "isec_cis_dev"; # SQL Server name (symbolic)
$odbc_pwd = "xxxxxxxxxx"; # SQL Server password
$odbc_uid = "xxxxx"; # SQL Server user id

$odbc_connect_string =
"DSN=$odbc_dsn;Servername=$odbc_server;Database=$odbc_db;UID=$odbc_uid;PWD=$
odbc_pwd";

(I *must* use SQL_CUR_USE_ODBC. Otherwise strange things happen)

$connection = odbc_connect ($odbc_connect_string, "", "", SQL_CUR_USE_ODBC)
or die ("Can not connect to $odbc_dsn.");

(Call a stored procedure on the MSSQL server, with appropriate parameters)

$sql = "EXEC ISTSLoadRecord $p_id_user, " . "'" . $s_id_suspense . "'";

$resultset = odbc_exec ($connection, $sql) or die ("Can not perform query");

# The first 3 lines are sample non-text data (bit, date, varchar). They
work.
# The last 2 lines are text data. They bomb.

if (odbc_fetch_row ($resultset))
{
$is_from = odbc_result ($resultset, "f_is_from");
$s_date_created = substr (odbc_result ($resultset, "f_date_created"), 0,
10);
$s_subject = odbc_result ($resultset, "f_subject");
$s_comment = odbc_result ($resultset, "f_comment");
$s_description = odbc_result ($resultset, "f_description");
}

Here's the error messages:

Warning: SQL error: [unixODBC][Driver Manager]Option value changed, SQL
state 01S02 in SQLGetData in /xxx/apache/html/edit.php on line 190

Warning: SQL error: [unixODBC][Driver Manager]Driver can not bind
parameters, SQL state S1000 in SQLGetData in /home/apache/html/edit.php on
line 191

The same code, using an ODBC-Bridge DSN (and no SQL cursor parameter in the
connect call), retrieves the text data OK.

Any ideas?

-Al Andersen

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









Archive powered by MHonArc 2.6.24.

Top of Page