Skip to Content.
Sympa Menu

freetds - Re: Hungry 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: Hungry PHP
  • Date: Sat, 11 Sep 1999 13:29:00 -0400 (EDT)



Netscape browser by chance? Have you tried it under IE or lynx by chance
and did it work there? If so check the PHP FAQ, you have a null trailing
'Schaap' after which netscape kindly discards everthing (until a newline?)
Anyway, I'm going to guess the real problem is varchar handling in
FreeTDS. Sybase's libs track the length of varchars in a structure
something like:

struct _cs_varchar {
CS_CHAR array[CS_MAX_STRING];
CS_INT length;
} CS_VARCHAR

and then the dblib structure is #define'd to this

(This is off the top of my head, I don't remember exactly what the ctlib
structure looks like, but close enough for this discussion). FreeTDS
doesn't track the length as such, it just always null terms. So there are
(under dblib) two basic ways to bind a string NTBSTRINGBIND (null term'd)
and STRINGBIND. I believe what is happening is one of the cases is
putting a null where it is not supposed to. It basically doesn't
have enough information to do the right thing.

So the short story is probably varchar has to be fixed, and that's going
to break alot of things. PHP probably stopped working because of changes
that were put to fix DBD::Sybase's behaviour.

So, anybody mind if I really screw up things for a few days?

brian

On Sat, 11 Sep 1999, Paul Schaap wrote:

> Brian,
>
> Following on from my previous MS SQL post here is some further details on
> the odd behaviour under php. Please note that under sqsh there is no
> problem.
>
> Here is a phtml
> ############################################################################
> <HTML>
> <HEAD>
> <TITLE>freetds kicks butt</TITLE>
> </HEAD>
> <BODY>
> <CENTER><H1><U>Hungry PHP</U></H1></CENTER>
> <?
> $cnn = sybase_pconnect("Your MS SQL Server","Login","Password")
> or die("Connect");
> $db = sybase_select_db("A Database",$cnn)
> or die("Select");
>
> // Surname is a VARCHAR
> $sql = "SELECT ID, Surname, ID
> FROM Customer
> WHERE ID = 10000696";
> echo "$sql<BR>";
> $qry = sybase_query($sql);
> if($qry){
> list($i1,$i2,$i3) = sybase_fetch_row($qry);
> echo "$i1 $i2 eat me $i3<BR>\n";
> echo "$i1 $i2 <B> eat me $i3</B><BR>\n";
> }
> sybase_free_result($qry);
>
> // WITH A CONVERT
> $sql = "SELECT ID, CONVERT(CHAR(20),Surname), ID
> FROM Customer
> WHERE ID = 10000696";
> echo "$sql<BR>";
> $qry = sybase_query($sql);
> if($qry){
> list($i1,$i2,$i3) = sybase_fetch_row($qry);
> echo "$i1 $i2 eat me $i3<BR>\n";
> echo "$i1 $i2 <B> eat me $i3</B><BR>\n";
> }
> sybase_free_result($qry);
> ?>
> </BODY>
> </HTML>
> ############################################################################
>
> Heres a possible schema, I'm not 100% on the MS SQL DB syntax ...
> ############################################################################
> CREATE TABLE Customer (
> ID INTEGER,
> Surname VARCHAR(255)
> );
> ############################################################################
>
> Heres the output on the Browser
> ############################################################################
> Hungry PHP
>
> SELECT ID, Surname, ID FROM Customer WHERE ID = 10000696
> 10000696 Schaap
> 10000696 Schaap eat me 10000696
> SELECT ID, CONVERT(CHAR(20),Surname), ID FROM Customer WHERE ID = 10000696
> 10000696 Schaap eat me 10000696
> 10000696 Schaap eat me 10000696
> ############################################################################
> notice the first 'eat me 10000696' on the first query just doesnt turn up.
> But the second one does turn up ? The tag entered on the second one somehow
> saves the data from dissappearing. A view source on the page also doesnt
> reveal the missing info hidden in a tag or anything, it just vanished !
>
> In the second query when I CONVERT all is well and as expected.
>
> REGARDS
> Paul
>





Archive powered by MHonArc 2.6.24.

Top of Page