Skip to Content.
Sympa Menu

freetds - Re: connecting to ms sql 6.5 from rh 5.2 with php

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT umcc.ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: connecting to ms sql 6.5 from rh 5.2 with php
  • Date: Sat, 29 May 1999 18:29:26 -0400 (EDT)


Okay, just tried it...here is the table setup I did using sqsh

1> create table brian (id int, name char(255))
2> go
1> insert brian values (1, 'test 1')
2> go
1> insert brian values (2, 'test 2...this is a really long test designed
to see if the problem is with the length of the column or if it is
something else...we must be at about 160 characters now and still going,
and some more stuff, and more, and a little more')
2> go
1>

Then the script: (error checking skipped for clarity)
---------------
<?
$cnn = sybase_connect("JDBC", "guest", "sybase");
$lnk = sybase_select_db("pubs2", $cnn);
$resultset = sybase_query("select * from brian", $lnk);

while ($results = sybase_fetch_row($resultset)) {
echo "Count " . count($results) . "\n";
for($i=0;$i<count($results);$i++)
echo $results[$i],' ';
echo "\n";
}
sybase_close($cnn);
?>

And finally the results:
-----------------------
[camber@amd133 php-3.0.8]# ./php test1.php
Msg 5701, Level 0, State 2, Server JDBC, Line 1
Changed database context to 'pubs2'.

Content-type: text/html

Count 2
1 test 1
Count 2
2 test 2...this is a really long test designed to see if the problem is
with the length of the column or if it is something else...we must be at
about 160 characters now and still going, and some more stuff, and more,
and a little more
[camber@amd133 php-3.0.8]#
-----------------

I noticed a couple things....
1) your original code had 'count(results)' I'm not sure if this is a
transcription error, but it prevented anything but the first column from
returning until I corrected it to 'count($results)'.
2) freetds is throwing the database change out on stderr, this will screw
up the http headers obviously...Look in token.c in the src/tds directory
in the function tds_process_msg and comment out the 'fprintf(stderr, ...'
lines.

Have you run php from the command line (ie not --with-apache ??), that
might give you a better indication of what is going on.

Regards,

Brian

On Sat, 29 May 1999, Christophe VG wrote:

> Brian Bruns wrote:
> > Hmmm...Are they char/varchar fields or actually 'text' datatypes? Text
> > datatypes have a whole set of dedicated functions to access. If they
> > are char or varchar please send me the table layout and I'll see what
> > I can do.
> > Brian
>
> Well, I've tried the following tables :
>
> test1
> =====
> name type size
> -------------------
> id int 4
> name varchar 255
> nick varchar 255
> text varchar 255
>
> test2
> =====
> name text 16
> fname text 16
> id int 4
>
> test3
> =====
> id int 4
> name char 255
>
> with the following php code :
>
> (there is some comment and a question inside :) )
>
> <?
>
> $cnn = sybase_connect("newton", "test", "test");
> /*
> ** When putting this on screen, it returns 1
> */
> if ($cnn == 0){
> echo "Unable to connect to newton.<BR>\n";
> exit;
>
> $lnk = sybase_select_db("test", $cnn);
> /*
> ** When putting this on screen, it also returns 1
> */
> if ($lnk == 0){
> echo "Unable to select db.<BR>\n";
> exit;
>
> /*
> ** Up to here everything seems to be allright.
> ** When the following command is called, I just can wait forever
> ** I noticed one strange thing, if I eg use the sql-statement :
> ** "select * from dummy", referring to a table that does not
> ** exist, I get no error message.
> ** Is this normal ?
> */
>
> $resultset = sybase_query("select * from test3", $lnk);
> if($resultset == 0){
> echo "No resultset returned.<br>\n";
> exit;
>
>
> $results = sybase_fetch_row($resultset);
>
> for($i=0;$i<count(results);$i++)
> echo $results[$i],' ';
>
> sybase_close($cnn);
>
>
> ?>
>
> I really think there must be some other problem, something like
> misconfiguration. I've downloaded the sybase server suite, and will be
> checking that one, some people mailed me to say it worked fine with
> them, using the same setup. Though I still hope to use freeTDS, since
> it's a lot lighter (and the problem got me intrigued).
>
> Anyhow, thanks a lot for all the effort you're putting into this.
>
> greetz,
> Christophe VG
>





Archive powered by MHonArc 2.6.24.

Top of Page